home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / LANGREF.TXT < prev    next >
Text File  |  1995-11-08  |  280KB  |  7,739 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                          NADIR
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                          Version  1.0
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                          LANGUAGE  REFERENCE
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                          Enexe Systems
  62.                          PO Box 771
  63.                          Ashgrove  4060  Qld
  64.                          Australia
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.                          Copyright  c  1994 by Enexe Systems.
  127.                          All rights are reserved.
  128.  
  129.  
  130.  
  131.  
  132.                          Licence Agreement
  133.  
  134.                          Carefully read the following terms and
  135.                          conditions.  If you do not agree, return the
  136.                          documents and unopened software for a refund.
  137.  
  138.                          The commercial version of Nadir must be treated
  139.                          like a book.  That is, one copy of the commercial
  140.                          version may be used by one person on one computer
  141.                          at a time.  If it is moved to another computer
  142.                          for use by another person, it must be removed
  143.                          from the original computer.  It may not be
  144.                          copied, except for taking backup copies for
  145.                          archive and security reasons.
  146.  
  147.                          A runtime version of Nadir is provided with the
  148.                          commercial version.  A system developed using the
  149.                          commercial version may be installed at a user
  150.                          site with the runtime version of Nadir.  No
  151.                          royalty fees are required to install the runtime
  152.                          version at a user site.
  153.  
  154.                          A product provided with the runtime version must
  155.                          be substantially different to the Nadir product.
  156.  
  157.                          A product that provides front-ends or
  158.                          enhancements to Nadir may not be installed at a
  159.                          user site without written permission from Enexe
  160.                          Systems.
  161.  
  162.                          The contents of any version of the product may
  163.                          not be modified in any way.
  164.  
  165.                          While every effort has been made, and will be
  166.                          made to provide a quality product, Enexe Systems
  167.                          will not be liable for any problems caused by the
  168.                          use of the product.
  169.  
  170.  
  171.  
  172.  
  173.         CONTENTS
  174.  
  175.  
  176.  
  177.  
  178.  
  179.                                                Null Value .............26
  180.         INTRODUCTION.................1         Boolean Value ..........26
  181.           Overview...................1       Variables ................26
  182.           Syntax Definitions.........3         Local Variables ........26
  183.           Command Line Definitions...3         Symbol Tables ..........27
  184.           General Comments...........3         Symbol Names ...........27
  185.                                                Subscripting ...........27
  186.         CHAPTER 1    LEXICAL  ELEMENTS         Collating Sequence .....28
  187.         .............................4         next, prev operators ...29
  188.           Whitespace.................4         Subscripting Symbol Table
  189.           Comments...................4         Names ..................29
  190.           Names......................4         Subscripting Function Names
  191.           Keywords...................4          .......................29
  192.           Operators..................5         Databases ..............30
  193.           String Constants...........6       Operand Conversion Rules .31
  194.             String Literals..........6         Arithmetic Operators ...31
  195.             Escape Sequences.........6         Comparison Operators ...32
  196.             Code Strings.............7
  197.           Numbers....................7     CHAPTER 4    EXPRESSIONS ...34
  198.                                              Operators ................34
  199.         CHAPTER 2    PROCESSING......8         >< Operator ............35
  200.             config.sys and autoexec.bat      Operator Precedence ......35
  201.             .........................8       Expression Syntax ........35
  202.           Command Line Syntax........8       Primary Expression .......37
  203.             Command Line Switches....9         Lvalue .................38
  204.             Single User Processing..12         Symbol .................38
  205.           Processing the Input File.13         Function Call ..........39
  206.             Initialization..........13         argc ...................40
  207.             Processing..............14         next ...................40
  208.             Macro Arguments.........15         prev ...................41
  209.             Redefining Keywords.....16         Logical negation ! .....41
  210.             Macro Definition........16         Unary minus - ..........41
  211.             Expression Evaluation...17         Parenthesis ............41
  212.             Conditional Keywords....18       Multiplicative Expression 42
  213.             Expansion Rules.........19       Additive Expression ......42
  214.             Processing the Input File        Relational Expression ....43
  215.             in a Macro..............20       Equality Expression ......44
  216.                                              Logical And Expression ...44
  217.         CHAPTER 3    LANGUAGE  OVERVIEW      Logical Or Expression ....44
  218.         ............................22       Conditional Expression ...45
  219.           Functions.................22       Assignment Expression ....45
  220.             Function Name...........22       Expression ...............46
  221.             Arguments...............22
  222.             Return Value............23     CHAPTER 5    STATEMENTS ....47
  223.             argv, argc..............23       Compound Statement .......48
  224.             Assigning Arguments.....23       Label Statement ..........48
  225.             Passing by value and by          Null Statement ...........49
  226.             reference...............23       Expression Statement .....49
  227.           Variable Types............24       Return Statement .........49
  228.             String..................25       If Statement .............50
  229.             Integer.................25       While Statement ..........50
  230.             Float...................25       Do Statement .............50
  231.             Date....................25       For Statement ............51
  232.  
  233.  
  234.  
  235.                                          i
  236.  
  237.  
  238.  
  239.  
  240.           Switch, Case and Default           System ...................76
  241.           Statements................51       SystemRestart ............76
  242.           Break Statement...........52       SysType ..................77
  243.           Continue Statement........52       TaskNum ..................77
  244.           Goto Statement............52       TimeNow ..................77
  245.                                              TokenNext ................77
  246.         CHAPTER 6    SYSTEM  INTRINSIC       TokenScanCreate ..........78
  247.         FUNCTIONS...................53       TokenScanDestroy .........79
  248.           Bunch.....................53       TokenTerm ................79
  249.           DateDay...................53       TokenType ................80
  250.           DateDayName...............53       TokenValue ...............80
  251.           DateMonth.................54       Unbunch ..................80
  252.           DateMonthEnd..............54
  253.           DateMonthName.............54     APPENDIX  A    SYSTEM
  254.           DateMonthStart............54     PARAMETERS .................82
  255.           DateToday.................55
  256.           DateYear..................55     APPENDIX  B    SYSTEM  LIMITS84
  257.           Dump......................55
  258.           Explode...................56     APPENDIX  C    SYMBOL  TABLE
  259.           Exit......................56     UTILITY - STU ..............88
  260.           FieldType.................57       Command Line Syntax ......88
  261.           FileClose.................57       STU Commands .............90
  262.           FileColumn................57         bstat - Brief Statistics90
  263.           FileDump..................57         check - Check Integrity 90
  264.           FileIndentSet.............58         copy - Copy Symbol Table92
  265.           FileLineGet...............58         dump - Dump Symbol Table92
  266.           FileOpen..................58         fstat - Full Statistics 92
  267.           FilePrint.................59         pack - Pack Symbol Table93
  268.           FileRemove................60         rbuild - Rebuild Symbol
  269.           FloatToInt................60         Table ..................94
  270.           Level.....................60         rtest - Random Test ....94
  271.           LineCurr..................61
  272.           LineGet...................61     APPENDIX  D   ERROR MESSAGES96
  273.           LineNum...................63       cnd - Condition Handler ..96
  274.           OutputColumn..............63       fm - File Manager ........96
  275.           OutputIndentSet...........63       hm - Handle Manager ......96
  276.           PreProcessSet.............63       key - Key File Functions .97
  277.           Print.....................64       lex - Lexical Analysis ...97
  278.           Process...................65       mem - Memory Manager .....98
  279.           Signal....................66       mi - Macro Interpreter ...98
  280.           Spawn.....................66       mif - Macro Intrinsic
  281.           SpawnRestart..............66       Functions ................99
  282.           StrCat....................67       mm - Macro Manager ......100
  283.           StrFromAscii..............67       mp - Macro Parsing ......102
  284.           StrFromLit................67       n - The main program ....106
  285.           StrFromQuoted.............68       st - Symbol Table .......107
  286.           StrLen....................69       vm - Virtual Memory .....107
  287.           StrMatch..................70
  288.           StrPos....................70     INDEX .....................109
  289.           StrSubs...................71
  290.           StrToAscii................71
  291.           StrToLit..................71
  292.           StrToLower................72
  293.           StrToUpper................72
  294.           SymClose..................72
  295.           SymCreate.................72
  296.           SymLock...................73
  297.           SymOpen...................74
  298.           SymRemove.................75
  299.  
  300.  
  301.  
  302.                                         ii
  303.  
  304.  
  305.  
  306.  
  307.         INTRODUCTION
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.         Overview
  316.  
  317.  
  318.  
  319.                          Nadir is a programming language.  It is designed
  320.                          to be simple yet intelligent, to reuse as many of
  321.                          its algorithms as possible to produce a small yet
  322.                          powerful programming system.
  323.  
  324.                          It combines powerful macro generation
  325.                          capabilities, with the ability to write
  326.                          procedural functions.  With it you can generate
  327.                          code for any language, analyse and manipulate
  328.                          text files, write database style applications
  329.                          that run unchanged under DOS and Windows, or even
  330.                          use it as a calculator.
  331.  
  332.                          The name Nadir, the opposite of the zenith, is
  333.                          used to signify a starting point, a small set of
  334.                          rules and functions upon which things can be
  335.                          built.  Enexe Systems has developed a product
  336.                          that will appeal to students, professional
  337.                          programmers, and the home enthusiast who wants a
  338.                          no frills programming system with a minimum of
  339.                          fuss and mumbo jumbo that is easy to learn
  340.                          because it is based on the syntax of C.
  341.  
  342.                          The base nucleus of Nadir comprises a number of
  343.                          modules that perform language parsing, language
  344.                          interpretation, error handling, and a set of
  345.                          inbuilt intrinsic functions for performing
  346.                          string, numeric and date maniplation, and the
  347.                          control of data files and the symbols in them.
  348.                          The nucleus is written in C, and has been ported
  349.                          to run under DOS and Windows.
  350.  
  351.                          Other modules of intrinsic functions have been
  352.                          written to perform Screen Dialogues and Report
  353.                          Formatting.  These functions have been written to
  354.                          perform under DOS in text mode and Windows.  When
  355.                          an application is written using these functions,
  356.                          it will work under DOS and Windows without
  357.                          change.
  358.  
  359.                          A Developer's Kit is planned to allow users to
  360.                          add modules of intrinsic functions written in C.
  361.                          Object modules of the nucleus will be provided,
  362.                          and customized versions of the Nadir programs can
  363.                          then be linked.
  364.  
  365.  
  366.  
  367.  
  368.  
  369.         Introduction                                                      1
  370.  
  371.  
  372.  
  373.  
  374.                          Nadir is designed to work with fields.  Being an
  375.                          interpreted language, it is slow when compared
  376.                          with programs written in C.  For writing
  377.                          applications, complex algorithms should be
  378.                          developed using C and made available by adding
  379.                          these algorithms to the language as intrinsic
  380.                          functions.  The Nadir code should be the 90% of
  381.                          the code that runs for 10% of the time.
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.         2                                            Nadir Reference Manual
  437.  
  438.  
  439.  
  440.  
  441.         Syntax Definitions
  442.  
  443.  
  444.  
  445.                          Syntax definitions consist of the entity being
  446.                          defined followed by a colon.  Alternatives follow
  447.                          on separate lines.  Optional elements are shown
  448.                          inside angle brackets
  449.  
  450.                 Example  macro-arg-list:
  451.                               ( macro-argument-list )
  452.                          macro-argument-list:
  453.                               macro-argument
  454.                               macro-argument-list, macro-argument
  455.                          macro-argument:
  456.                               user-defined-word < macro-arg-list >
  457.                               token
  458.                               macro-argument terminator token
  459.  
  460.                          A macro-arg-list is a left parenthesis, followed
  461.                          by an macro-argument-list, followed by a right
  462.                          parenthesis.
  463.                          A macro-argument-list is a macro-argument or a
  464.                          macro-argument-list followed by a comma and a
  465.                          macro-argument.
  466.                          A macro-argument is either a user-defined-word,
  467.                          followed by an optional macro-arg-list, or a
  468.                          token, or a macro-argument followed by a
  469.                          terminator and a token.
  470.  
  471.         Command Line Definitions
  472.  
  473.  
  474.  
  475.                          When the syntax of commands are shown, brackets,
  476.                          [], are used to show optional items.
  477.  
  478.                 Example  stu command [switches] [file1 [file2]]
  479.  
  480.                          The user must specify the command word, the
  481.                          switches, file1 and file2 are optional.
  482.  
  483.         General Comments
  484.  
  485.  
  486.  
  487.                          All the examples show the date in the dd/mm/yyyy
  488.                          format.  There is a system parameter that allows
  489.                          the output format of the date to be modified.
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.         Introduction                                                      3
  504.  
  505.  
  506.  
  507.  
  508.         CHAPTER 1    LEXICAL  ELEMENTS
  509.  
  510.  
  511.  
  512.  
  513.  
  514.                          This chapter provides a formal definition of the
  515.                          Nadir lexical elements.  When an input file is
  516.                          read, it is broken into components known as
  517.                          lexical elements or tokens.  The syntax of the
  518.                          Nadir language, or the legal combination of
  519.                          tokens is dealt with in the following chapters.
  520.  
  521.                          In Nadir, case is significant. i.e. The name
  522.                          MyMacro is considered to be a different name to
  523.                          mymacro.
  524.  
  525.         Whitespace
  526.  
  527.  
  528.  
  529.                          Whitespace is used to separate tokens in the
  530.                          input file. The whitespace characters are space,
  531.                          tab, carriage return, newline, vertical tab and
  532.                          formfeed.  Any amount of whitespace may be used
  533.                          to separate the tokens in the input file.
  534.  
  535.         Comments
  536.  
  537.  
  538.  
  539.                          Comments may be used to write notes in the
  540.                          program source.  The contents of the comment text
  541.                          are ignored.  Comments may be defined in two
  542.                          ways.
  543.  
  544.              /* .... */  The character pair /* begins the comment.  The
  545.                          comment ends with the next occurence of  the
  546.                          character pair */.
  547.  
  548.                // .....  The character pair // begins the comment.  The
  549.                          comment ends with the next newline character.
  550.  
  551.         Names
  552.  
  553.  
  554.  
  555.                          A name starts with an alphabetic character or the
  556.                          underscore character, and may contain any number
  557.                          of alphanumeric or underscore characters.  The
  558.                          name ends when a character that is not an
  559.                          alphanumeric or an underscore is encountered.
  560.  
  561.         Keywords
  562.  
  563.  
  564.  
  565.                          Keywords are special forms of a name.
  566.  
  567.  
  568.  
  569.  
  570.         4                                            Nadir Reference Manual
  571.  
  572.  
  573.  
  574.  
  575.                          The following words have special meaning when
  576.                          processing the input file.
  577.  
  578.                          Define    Eval
  579.                          If        Elseif    Else      Endif
  580.  
  581.                          The following words are reserved words when
  582.                          defining macros.  These words may not be used as
  583.                          variable names or components in variable names.
  584.  
  585.                          if        else      return    do        while
  586.                          for       switch    goto      break
  587.                               continue
  588.                          argv      argc      next      prev
  589.  
  590.         Operators
  591.  
  592.  
  593.  
  594.                          Operators are sequences of non alphabetic
  595.                          characters.  The following table gives each
  596.                          operator and a short description of their use.
  597.                          Later chapters describe the operators in more
  598.                          detail.
  599.  
  600.                          Operat  Description and use
  601.                          or
  602.  
  603.                          {       Begin compound statement
  604.                          }       End compound statement
  605.                          (       Argument list definition, set expression
  606.                                  precedence
  607.                          )
  608.                          [       Begin subscript
  609.                          ]       End Subscript
  610.                          ,       Argument separator
  611.                          ><      Argument separator
  612.                          ;       Statement terminator
  613.                          +       Addition
  614.                          -       Subtraction, unary minus
  615.                          .       Concatenation
  616.                          *       Multiplication
  617.                          /       Division
  618.                          %       Modulus (remainder)
  619.                          ?       Conditional operator
  620.                          :       Conditional operator
  621.                          =       Assignment operator
  622.                          +=      Assign sum
  623.                          -=      Assign difference
  624.                          *=      Assign product
  625.                          /=      Assign quotient
  626.                          %=      Assign modulus
  627.                          .=      Assign concatenation
  628.                          ==      Logical equal to
  629.                          !       Logical not
  630.                          !=      Logical not equal to
  631.                          <       Logcal less than
  632.                          <=      Logical less than or equal to
  633.                          >       Logical greater than
  634.  
  635.  
  636.  
  637.         Chapter 1    Lexical Elements                                     5
  638.  
  639.  
  640.  
  641.  
  642.                          >=      Logical greater than or equal to
  643.                          &&      Logical and
  644.                          ||      Logical or
  645.                          ^       Variable component seperator
  646.  
  647.         String Constants
  648.  
  649.  
  650.  
  651.                          There are two types of string constants, string
  652.                          literals and code strings.
  653.  
  654.         String Literals
  655.  
  656.                          String literals begin and end with matching
  657.                          single or double quotes.  In Nadir, the use of
  658.                          single and double quotes is interchangeable.
  659.  
  660.                          Stings may be continued onto the next line by
  661.                          using the backslash newline combination at the
  662.                          end of the first line.
  663.  
  664.                 Example  "abcd"
  665.  
  666.                          'abcd'
  667.  
  668.                          "ab\
  669.                          cd"
  670.  
  671.                          all specify strings containing 4 characters,
  672.                          abcd.
  673.  
  674.         Escape Sequences
  675.  
  676.                          Escape sequences are necessary to allow the
  677.                          definition of non printable characters in a
  678.                          string literal.  They also allow the definition
  679.                          of double quotes in a string literal that begins
  680.                          and ends with double quotes.
  681.  
  682.                          The valid escape sequences are shown in the
  683.                          following table.
  684.  
  685.                          Sequen  Char   Remarks
  686.                          ce
  687.  
  688.                          \a      BEL    Audible bell
  689.                          \b      BS     Backspace
  690.                          \f      FF     Formfeed
  691.                          \n      LF     Linefeed
  692.                          \r      CR     Carriage return
  693.                          \t      HT     Horizontal tab
  694.                          \v      VT     Vertical tab
  695.                          \\      \      Backslash
  696.                          \'      '      Single quote
  697.                          \"      "      Double quote
  698.                          \xhh           hh, a string of up to 2
  699.                                         hex digits
  700.                          \Xhh           hh, up to 2 hex digits
  701.  
  702.  
  703.  
  704.         6                                            Nadir Reference Manual
  705.  
  706.  
  707.  
  708.  
  709.                          \ooo           ooo, up to 3 octal
  710.                                         digits
  711.  
  712.                   Notes  If a character that follows a backslash is not in
  713.                          the list above, it is taken to mean the character
  714.                          itself.  eg \z is lowercase z, \? is question
  715.                          mark.
  716.  
  717.                          The hex string after \x or \X ends with the first
  718.                          non hexadecimal character.  eg "\x7g" is two
  719.                          characters, a character with a value of 7,
  720.                          followed by lowercase g.
  721.  
  722.                          If a digit between 0 and 7 follows the backslash,
  723.                          it is assumed to start an octal string.  The
  724.                          octal string ends with the first non octal
  725.                          character, or an octal character that would make
  726.                          the character value more that octal 377.  eg
  727.                          \777 is taken to mean 2 characters, one with an
  728.                          octal value of 77, followed by the character 7.
  729.  
  730.  
  731.  
  732.         Code Strings
  733.  
  734.                          Code strings start and end with a matching accent
  735.                          ` character.  Each character in the input file is
  736.                          placed in the code string.  There are no escape
  737.                          sequences and it is not possible to have an
  738.                          accent in a code string.
  739.  
  740.                 Example  `abc
  741.                          def`
  742.  
  743.                          "abc\ndef"
  744.  
  745.                          are equivalent.  Both specify strings of 7
  746.                          characters, abc newline def.
  747.  
  748.         Numbers
  749.  
  750.  
  751.  
  752.                          There are two types of numeric tokens, integer
  753.                          and floating point.
  754.  
  755.                          Integers contain decimal digits. eg 1234  All
  756.                          integers are stored internally as 32 bit signed
  757.                          integers.
  758.  
  759.                          Floating point numbers contain a decimal point.
  760.                          The integer before the decimal point and the
  761.                          fraction part after the decimal point must either
  762.                          be specified.  eg  .2,  22. and 22.22 are valid
  763.                          floating point numbers.  A dot on its own is not
  764.                          seen as a floating point constant of zero.
  765.                          Floating point numbers are stored internally as
  766.                          double precision floating point numbers.
  767.  
  768.  
  769.  
  770.  
  771.         Chapter 1    Lexical Elements                                     7
  772.  
  773.  
  774.  
  775.  
  776.         CHAPTER 2    PROCESSING
  777.  
  778.  
  779.  
  780.  
  781.  
  782.                          The Nadir program is a filter.  It takes input
  783.                          from an input file and writes output to an output
  784.                          file.
  785.  
  786.                          This chapter describes the command line syntax
  787.                          and the method Nadir uses to process the input
  788.                          file to produce the output file.
  789.  
  790.                          The runtime version of Nadir does not allow the
  791.                          processing of an input file.  Applications may be
  792.                          executed using the runtime version using the -e
  793.                          or -p command line switches.
  794.  
  795.                          There are two versions of the Nadir program.
  796.                          n.exe is the version that runs in text mode under
  797.                          DOS.  nw.exe and nsys.dll are the files that run
  798.                          under Windows.
  799.  
  800.         config.sys and autoexec.bat
  801.  
  802.                          The FILES statement in config.sys must allow for
  803.                          the number of files that are to be opened.  This
  804.                          figure has to allow for all the files that are
  805.                          opened at one time by all active Windows tasks.
  806.  
  807.                          If files are to be shared, the DOS SHARE program
  808.                          has to be loaded.  This can be done in config.sys
  809.                          using the INSTALL statement, or by running the
  810.                          program directly in autoexec.bat.  The /f and /l
  811.                          switches may be specified to manage the number of
  812.                          files that are to be shared.  See the Nadir -s
  813.                          switch and the section Single User Processing
  814.                          later in this chapter.
  815.  
  816.                          The following statement in config.sys will load
  817.                          the share program, allocate 3072 bytes for
  818.                          storing file sharing information and specifies
  819.                          that 64 files can be locked at one time.
  820.  
  821.                          INSTALL C:\DOS\SHARE.EXE /F:3072 /L:64
  822.  
  823.         Command Line Syntax
  824.  
  825.  
  826.  
  827.             DOS Command  n [switches] [<infile] [>outfile] [infile]
  828.  
  829.         Windows Command  nw [switches] [infile]
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.         8                                            Nadir Reference Manual
  839.  
  840.  
  841.  
  842.  
  843.                          Under DOS the default input file is standard
  844.                          input and the default output file is standard
  845.                          output.  They may be redefined by using the > and
  846.                          < redirection operators, or the -i and -o command
  847.                          line switches.
  848.  
  849.                 Windows  Windows does not provide standard input or
  850.            Input/Output  standard output or the < and > redirection
  851.                          operators when processing a command.  To specify
  852.                          input, use the -i switch or specify an infile on
  853.                          the command line.  If -i is not specified, the
  854.                          first time data is requested from the input file,
  855.                          end of file is returned.  If -o is not specified,
  856.                          all output is collected in a temporary file and
  857.                          presented to the user using the browser.  See
  858.                          Appendix A, System Parameters for details
  859.                          specifying a browser.
  860.  
  861.         Command Line Switches
  862.  
  863.                          Switches may be specified by either a minus sign
  864.                          or a slash.  Spaces may be optionally present
  865.                          between the switch name and the switch value.  If
  866.                          a switch is specified more than once the last
  867.                          value will be used.  If the -i switch is used and
  868.                          the infile argument is also specified, the last
  869.                          one specified will be used.
  870.  
  871.                          Switch    Description
  872.  
  873.                          -a<name>  After processing, the macro specified
  874.                                    by name is executed.
  875.  
  876.                          -b<name>  Before processing is performed, the
  877.                                    macro specified by name is executed.
  878.                                    The macro is executed once.  If an
  879.                                    error is signalled and the -c switch
  880.                                    is active, it will not be re-executed.
  881.                                    The same comment applies to the -a
  882.                                    switch.
  883.  
  884.                          -c        Cycle on errors
  885.                                    If an error is signalled and the -c
  886.                                    switch is active, Nadir will release
  887.                                    all resources such as memory and file
  888.                                    handles and restart the program.
  889.  
  890.                                    If the switch is not specified, the
  891.                                    program terminates when an error is
  892.                                    signalled.  In this case, the return
  893.                                    code of the Nadir program will be 20.
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.         Chapter 2    Processing                                           9
  906.  
  907.  
  908.  
  909.  
  910.                          -e<name>  Execute Macro.
  911.                                    The macro specified by name is
  912.                                    executed.  The input file is not
  913.                                    processed.  This is similar to -p, but
  914.                                    is more efficient because the memory
  915.                                    used by the macro compiler is not
  916.                                    allocated
  917.  
  918.                                    Data may be read from the input file
  919.                                    using system intrinsic functions.  Any
  920.                                    return value from the macro is
  921.                                    discarded.
  922.  
  923.                          -i<name>  Input filename.
  924.                                    name specifies the input filename.
  925.                                    Under DOS, if -i is not specified,
  926.                                    input is read from standard input.
  927.                                    Under Windows, if -i is not specified,
  928.                                    any attempt to read from the input
  929.                                    file will immediately return end of
  930.                                    file.  Under Windows, if -i is not
  931.                                    specified, -e or -p must be specified
  932.                                    for Nadir to perform a task.
  933.  
  934.                          -l        Use macro library.
  935.                                    If specified, Nadir will open the
  936.                                    default macro library, mlib.dat, on
  937.                                    startup.  Any reference to a user
  938.                                    written macro, or symbol that is not
  939.                                    found in the mdat symbol table, is
  940.                                    searched for in the macro library.
  941.                                    If the -L switch is used, -l is
  942.                                    assumed.
  943.                                    If -l, or -L is not used, Nadir will
  944.                                    not open a library.
  945.  
  946.                          -         No Keywords.
  947.                          n[flags]  This is used to pre-process Nadir
  948.                                    code.  It allows the user to ignore
  949.                                    some or all keywords in the input
  950.                                    file.  Keywords are If, Else, Elseif,
  951.                                    Endif, Eval and Define.
  952.                                    flags is optional and is a string that
  953.                                    may contain :-
  954.                                    d - Ignore Define keyword
  955.                                    e - Ignore Eval
  956.                                    i - Ignore If, Elseif, Else and Endif
  957.                                    If flags is not specified, dei is
  958.                                    assumed.
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.         10                                           Nadir Reference Manual
  973.  
  974.  
  975.  
  976.  
  977.                          -o<name>  Output filename.
  978.                                    name specifies the output filename.
  979.                                    Under DOS, if the -o switch is not
  980.                                    specified, output is written to
  981.                                    standard output.
  982.                                    Under Windows, name is optional.  If
  983.                                    specified, output is directed to a
  984.                                    file with that name.  If -o is
  985.                                    specified without name, output is
  986.                                    written to a temporary file and is
  987.                                    shown using the browser program after
  988.                                    the Nadir program finishes processing.
  989.                                    If -o is not specified under Windows,
  990.                                    all output is discarded.
  991.  
  992.                          -         Process String
  993.                          p<string  The string is processed as if it
  994.                          >         occurred in the input file.
  995.                                    Processing is complete when data from
  996.                                    the string is exhausted.  Data may be
  997.                                    read from the input file using system
  998.                                    intrinsic functions.
  999.  
  1000.                          -r        Reset input on errors.
  1001.                                    If the program cycles after an error,
  1002.                                    this switch will cause Nadir to start
  1003.                                    processing at the start of the input
  1004.                                    file.
  1005.  
  1006.                          -s        Single User Mode
  1007.                                    When specified, files are not opened
  1008.                                    shared, no locking is performed, and
  1009.                                    the special single user processing on
  1010.                                    incorrectly opened files is performed.
  1011.  
  1012.                          -D<dir>   Default Data Directory
  1013.                                    If a full pathname is not specified
  1014.                                    when a symbol table is opened, Nadir
  1015.                                    uses the dir value to specify the
  1016.                                    directory.  If not specified, files
  1017.                                    will be opened in the default
  1018.                                    directory.
  1019.  
  1020.                          -L<name>  Library data symbol table filename.
  1021.                                    name specifies the filename of a macro
  1022.                                    library symbol table.  This file
  1023.                                    contains compiled definitions of
  1024.                                    macros.
  1025.  
  1026.                          -M<name>  Macro data symbol table filename.
  1027.                                    name specifies the filename of the
  1028.                                    macro data symbol table.  This data
  1029.                                    file contains the compiled definitions
  1030.                                    of macros.
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.         Chapter 2    Processing                                          11
  1040.  
  1041.  
  1042.  
  1043.  
  1044.                          -P<name>  Parameters symbol table filename.
  1045.                                    name specifies the filename of the
  1046.                                    symbol table containing system
  1047.                                    parameters.
  1048.  
  1049.                          -         Size of local value stack.
  1050.                          Sl<size>  Local variables may be defined in
  1051.                                    macros.  Their values are kept on the
  1052.                                    local value stack.  size specifies the
  1053.                                    size in bytes of the local value
  1054.                                    stack.  If not specified, size
  1055.                                    defaults to 4096 bytes.
  1056.  
  1057.                          -         Memory Block Size.
  1058.                          Sm<size>  This applies to the Windows version
  1059.                                    only.  Dynamic memory is obtained from
  1060.                                    the operating system in chunks of size
  1061.                                    bytes.  Nadir then manages these
  1062.                                    chunks to provide dynamic memory
  1063.                                    allocation.  If memory is required,
  1064.                                    and there is not enough free memory in
  1065.                                    the chunks that have been obtained,
  1066.                                    Nadir will request another block from
  1067.                                    the Operating System.  If -Sm switch
  1068.                                    is not used, memory block size
  1069.                                    defaults to 40960 bytes.
  1070.  
  1071.                          -         Size of operand stack.
  1072.                          So<size>  The operand stack is used to hold
  1073.                                    values when expressions are evaluated
  1074.                                    when executing compiled macro code.
  1075.                                    size specifies the size in bytes of
  1076.                                    the operand stack.  If not specified,
  1077.                                    size defaults to 4096 bytes.
  1078.  
  1079.                          -T<dir>   Temporary File Directory
  1080.                                    dir specifies the directory where
  1081.                                    temporary files are created.  All
  1082.                                    temporary files created by Nadir have
  1083.                                    a "$$$" extension.  If not specified,
  1084.                                    temporary files are created in the
  1085.                                    default directory.
  1086.  
  1087.                          -U<name>  Universal symbol table filename.
  1088.                                    name specifies the filename of the
  1089.                                    universal symbol table.  Universal
  1090.                                    symbols are permanent and may be kept
  1091.                                    after invokations of Nadir.
  1092.  
  1093.         Single User Processing
  1094.  
  1095.                          When the single user switch -s is specified, no
  1096.                          file sharing is possible.  The DOS SHARE program
  1097.                          does not have to be loaded.  If the -s switch is
  1098.                          not specified, the SHARE program must be loaded
  1099.                          before running Nadir.
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.         12                                           Nadir Reference Manual
  1107.  
  1108.  
  1109.  
  1110.  
  1111.                          When using single user mode, a check is made when
  1112.                          each file is opened as to whether it was properly
  1113.                          closed.  If it was not properly closed, the open
  1114.                          routine calls a user written function called
  1115.                          SysFileRecover with one argument, the name of the
  1116.                          file.  This function can allow the user to check
  1117.                          or restore the file.  If this program uses the
  1118.                          check option of the symbol table utility, stu,
  1119.                          and the file has no errors, the utility will
  1120.                          reset the improperly open flag in the file.
  1121.  
  1122.                          If the SysFileRecover function does not exist,
  1123.                          the program will be exited with a message "Symbol
  1124.                          Table blah not properly closed".
  1125.  
  1126.         Processing the Input File
  1127.  
  1128.  
  1129.  
  1130.         Initialization
  1131.  
  1132.                          When Nadir is started, default symbol tables are
  1133.                          opened.  Symbol tables are used to store the
  1134.                          values of symbols.  Symbols are variables and may
  1135.                          be manipulated when macros are executed.  Symbols
  1136.                          are referenced in the macro language by using a
  1137.                          prefix like univ, glob, parm, and mdat.  The
  1138.                          symbol tables that are always opened are
  1139.                          described below.  Intrinsic functions allow
  1140.                          access to other symbol tables.
  1141.  
  1142.                    univ  The universal table is a permanent symbol table.
  1143.                          Permanent symbol tables may be used to store data
  1144.                          from one invokation of Nadir and refer to it by a
  1145.                          later invokation.  The universal table may also
  1146.                          be shared.  A shared table may be opened by
  1147.                          simultaneous invokations of Nadir, either in
  1148.                          different tasks under Windows, on different DOS
  1149.                          boxes under Windows, or on different machines on
  1150.                          a network.
  1151.  
  1152.                    glob  The global table is temporary.  On each
  1153.                          invokation, a table is created, and deleted when
  1154.                          Nadir exits.  Unlike univ, global data cannot be
  1155.                          shared between sessions running simultaneously.
  1156.                          Each invokation of Nadir will have a separate
  1157.                          global symbol table.
  1158.  
  1159.                    mdat  The macro data file is a permanent table that may
  1160.                          be shared.  This file contains the compiled macro
  1161.                          definitions.  When macros are defined using the
  1162.                          Define word, the code is analysed syntactically,
  1163.                          converted to an internal form and stored in
  1164.                          symbols in the mdat file.  When a macro is
  1165.                          evaluated, the internal form is interpreted to
  1166.                          execute the statements in the macro.
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.         Chapter 2    Processing                                          13
  1174.  
  1175.  
  1176.  
  1177.  
  1178.                          mdat is not limited to storing compiled macro
  1179.                          code and may also contain any symbols that the
  1180.                          user chooses to store.
  1181.  
  1182.                    parm  The parameter file is a permanent file that may
  1183.                          be shared.  Its purpose is to contain system and
  1184.                          user defined parameters.
  1185.  
  1186.                          System parameters are used to alter the behaviour
  1187.                          of Nadir, and are read from the parm file during
  1188.                          initialization.  See an appendix for details.
  1189.  
  1190.                    mlib  The macro library, mlib, is opened only if the -l
  1191.                          or -L startup parameters are specified.
  1192.  
  1193.                          Any reference to a macro definition or a symbol
  1194.                          in mdat that is not found is attemped in mlib.
  1195.  
  1196.         Processing
  1197.  
  1198.                          The input file is lexically analysed.  If a token
  1199.                          is not a name, the token is written to the output
  1200.                          file. The whitespace before the token is also
  1201.                          output.  See Chapter 1 for information on Lexical
  1202.                          Analysis.
  1203.  
  1204.                          There are six words that are reserved and have
  1205.                          special meaning when Nadir processes the input
  1206.                          file.  They are If, Elseif, Else, Endif, Eval and
  1207.                          Define.  The behaviour of these words in the
  1208.                          input file is described below.
  1209.  
  1210.                          If a name is not one of the reserved words, mdat
  1211.                          and optionally mlib are checked to see if the
  1212.                          word is a user-defined macro.  If the name is not
  1213.                          user defined, it is output to the output file,
  1214.                          and the processing of the input file continues.
  1215.                          If there are no user defined words and no
  1216.                          reserved words in the input file, the output file
  1217.                          will be the same as the input file.
  1218.  
  1219.                          If the name is user defined, the value of the
  1220.                          macro with that name is output.  Nadir first
  1221.                          searches the mdat file for the word.  If the word
  1222.                          is not found, and the -l ot -L command line
  1223.                          switch has been used, Nadir will then search the
  1224.                          macro library, mlib.
  1225.  
  1226.                          If a macro is found it is executed and the value
  1227.                          returned by the macro is output.  Macros are
  1228.                          defined by using the Define keyword.
  1229.  
  1230.                          If an argument list exists after the name of the
  1231.                          macro in the input file, the value returned by
  1232.                          the macro replaces the macro name and the
  1233.                          argument list in the input file.  Argument lists
  1234.                          are described in more detail in a later section.
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.         14                                           Nadir Reference Manual
  1241.  
  1242.  
  1243.  
  1244.  
  1245.                          Macros, when executed may perform the Print
  1246.                          intrinsic function.  The output of the Print
  1247.                          function is put in the output file before the
  1248.                          return value of the macro is output.
  1249.  
  1250.         Macro Arguments
  1251.  
  1252.                          Arguments may be optionally passed to a macro
  1253.                          when a user defined word in the input file is the
  1254.                          name of a macro.  The syntax of an argument list
  1255.                          is :-
  1256.  
  1257.                          macro-arg-list:
  1258.                               ( macro-argument-list )
  1259.                          macro-argument-list:
  1260.                               macro-argument
  1261.                               macro-argument-list, macro-argument
  1262.                          macro-argument:
  1263.                               user-defined-word < macro-arg-list >
  1264.                               token
  1265.                               macro-argument terminator token
  1266.  
  1267.                          If a user defined word is encountered, the return
  1268.                          value of the macro replaces the text in the input
  1269.                          file.
  1270.  
  1271.                          Arguments to macros that are invoked during
  1272.                          processing are always passed as strings, exactly
  1273.                          as they appear in the input file.  Arguments are
  1274.                          separated by commas, and if more than one word
  1275.                          appears before the next comma, the words and the
  1276.                          intervening whitespace, the terminators, are
  1277.                          concatenated into one string.
  1278.  
  1279.                 Example  String in input file     Remarks
  1280.  
  1281.                          MacroName(abcd)          Macro called with a
  1282.                                                   string of four
  1283.                                                   characters, abcd.
  1284.  
  1285.                          MacroName(abcd, efgh)    Called with 2 arguments
  1286.                                                   4 character string abcd
  1287.                                                   4 character string efgh.
  1288.  
  1289.                          MacroName(abcd efgh,     Called with 2 arguments
  1290.                          1234 5678)               9 character string abcd
  1291.                                                   efgh
  1292.                                                   9 character string 1234
  1293.                                                   5678
  1294.  
  1295.                          MacroName("abcd\nefgh")  Called with 1 argument
  1296.                                                   12 character string,
  1297.                                                   which includes the
  1298.                                                   double quotes, and a
  1299.                                                   backslash.
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.         Chapter 2    Processing                                          15
  1308.  
  1309.  
  1310.  
  1311.  
  1312.                          MacroName("abcd\         Called with 1 argument
  1313.                          efgh")                   12 character string,
  1314.                                                   which includes the
  1315.                                                   double quotes, a
  1316.                                                   backslash and a newline.
  1317.  
  1318.  
  1319.  
  1320.         Redefining Keywords
  1321.  
  1322.                          Keywords have special meaning when processing
  1323.                          input.  The keywords are Define, Eval, If,
  1324.                          Elseif, Else and Endif.  The values of the words
  1325.                          may be changed by setting system parameters in
  1326.                          the parm symbol table.  i.e. symbol
  1327.                          parm^system^word^Define may be used to redefine
  1328.                          the word Define to for example DEFINE_A_MACRO.
  1329.                          See Appendix A for more information on these
  1330.                          System Parameters.
  1331.  
  1332.         Macro Definition
  1333.  
  1334.                  Define  The Define keyword is used to define or create a
  1335.                          macro.  If a macro exists, it is overwritten with
  1336.                          the new definition.  When macros are defined, the
  1337.                          macro text is compiled into an internal form that
  1338.                          is used when the macro is executed.  This
  1339.                          internal form is stored in symbols in the mdat
  1340.                          symbol table.
  1341.  
  1342.                          The syntax of the Define statement is :-
  1343.  
  1344.                          Define macro-name <(<arg-name-list>)> compound-
  1345.                          statement
  1346.  
  1347.                          macro-name:
  1348.                               name
  1349.                               macro-name ^ <name>
  1350.  
  1351.                          arg-name-list:
  1352.                               name
  1353.                               arg-name-list , name
  1354.  
  1355.                          The macro name may contain carets.  If a caret is
  1356.                          not present, the macro is saved in the mdat
  1357.                          symbol table.  If a caret is present, the name
  1358.                          component before the first caret specifies the
  1359.                          symbol table where the macro is saved.  The name
  1360.                          of the macro in the symbol table is the macro-
  1361.                          name with the first name component and the first
  1362.                          caret removed.
  1363.  
  1364.                          The optional arg-name-list allows the definition
  1365.                          of argument names that are used in the body of
  1366.                          the macro to refer to the arguments passed to the
  1367.                          macro.  The arg-list can be empty, or can have
  1368.                          any number names, separated by commas.
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.         16                                           Nadir Reference Manual
  1375.  
  1376.  
  1377.  
  1378.  
  1379.                          The compound statement defines the processing
  1380.                          that is performed when the macro is invoked.  The
  1381.                          syntax of a compound statement is defined in a
  1382.                          later section. Briefly, it is a series of
  1383.                          statements enclosed in matching braces {}.  If a
  1384.                          return statement is processed, the value returned
  1385.                          by the macro is the value of the expression after
  1386.                          the return keyword.  If the compound statement
  1387.                          does not have a return statement, the null value
  1388.                          is returned.
  1389.  
  1390.                 Example  The following example shows the definition of a
  1391.                          macro that takes 2 arguments, and some
  1392.                          invokations of it.
  1393.  
  1394.                          Define Adder(a1, a2) {
  1395.                              return a1 + a2;
  1396.                          }
  1397.                          3 + 2 is Adder(3,2)
  1398.                          3 + nothing is Adder(3) or Adder (3,)
  1399.  
  1400.                          When this is processed, the following output is
  1401.                          produced.
  1402.  
  1403.                          3 + 2 is 5
  1404.                          3 + nothing is 3 or 3
  1405.  
  1406.         Expression Evaluation
  1407.  
  1408.                    Eval  Eval is used to evaluate expressions when
  1409.                          processing input.  The syntax of the Eval
  1410.                          statement may be one of two forms.
  1411.  
  1412.                          Eval ( expression )
  1413.                          Eval compound-statement
  1414.  
  1415.                          The text of the Eval statement is replaced by its
  1416.                          evaluation.
  1417.  
  1418.                          When parenthesis are used, the expression is
  1419.                          evaluated, and its value output.  The closing
  1420.                          right parenthesis is not required if the
  1421.                          expression occurs at the end of the input.
  1422.  
  1423.                          In the second case, the compound statement is
  1424.                          evaluated as if it was a macro.  The return
  1425.                          statement is used to set a return value.  If a
  1426.                          return statement is not processed, the null value
  1427.                          is returned.
  1428.  
  1429.                          In either case, the text of the expression or the
  1430.                          compound statement is compiled into the internal
  1431.                          form using the macro language syntax rules, and
  1432.                          then evaluated.
  1433.  
  1434.                Examples  When the following text is processed
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.         Chapter 2    Processing                                          17
  1442.  
  1443.  
  1444.  
  1445.  
  1446.                          Today, Eval(DateToday()) is Eval {
  1447.                              dayName = DateDayName(DateToday());
  1448.                              if (dayName == "Saturday" || dayName ==
  1449.                          "Sunday")
  1450.                                  return "on the weekend";
  1451.                              else
  1452.                                  return "a week day";
  1453.                          }
  1454.  
  1455.                          The following text is output, (if you run it on
  1456.                          24/11/1993)
  1457.  
  1458.                          Today, 24/11/1993 is a week day
  1459.  
  1460.         Conditional Keywords
  1461.  
  1462.                          The words If, Elseif, Else and Endif may be used
  1463.                          to conditionally process blocks of text in the
  1464.                          input file.  For each If, there may be any number
  1465.                          of Elseif keywords and there must be a matching
  1466.                          Else or Endif.  For every Else, there must be a
  1467.                          matching Endif.
  1468.  
  1469.                          The keywords may be used as follows
  1470.  
  1471.                          If ( expression-1 )
  1472.                          <section-1>
  1473.                          <Elseif ( expression-2 ) section-2>
  1474.                          ....
  1475.                          <Elseif ( expression-n ) section-n>
  1476.                          <Else else-section>
  1477.                          <Endif>
  1478.  
  1479.                          If expression-1 evaluates to true, the text
  1480.                          represented by section-1 is processed.
  1481.                          Otherwise, if expression-1 evaluates to false,
  1482.                          section-1 is ignored (not processed).
  1483.  
  1484.                          When an expression is evaluated, it is evaluated
  1485.                          using the macro language rules of syntax and
  1486.                          execution.  In effect, the expression is compiled
  1487.                          like a macro, and then executed.  This, and the
  1488.                          values of true and false expressions are defined
  1489.                          in a later section.
  1490.  
  1491.                          In the true case, after section-1 has been
  1492.                          preprocessed, control passes to the matching
  1493.                          Endif.  When expression-1 is false, control
  1494.                          passes to the next Elseif directive, where
  1495.                          expression-2 is evaluated.  If expression-2
  1496.                          evaluates to true, section-2 is processed and
  1497.                          control passes to the matching Endif.  Otherwise
  1498.                          if expression-2 is false, control passes to the
  1499.                          next Elseif, and so on, until either Else or
  1500.                          Endif is encountered.  The optional else-section
  1501.                          is processed when no other section has been
  1502.                          processed.  The else-section ends with the
  1503.                          matching Endif.
  1504.  
  1505.  
  1506.  
  1507.  
  1508.         18                                           Nadir Reference Manual
  1509.  
  1510.  
  1511.  
  1512.  
  1513.                          The If, Elseif, Else, Endif structure may be
  1514.                          nested.
  1515.  
  1516.         Expansion Rules
  1517.  
  1518.                          When expanding, comments are retained and written
  1519.                          to the output file wherever possible.
  1520.  
  1521.                          The comment after a user defined word is not
  1522.                          output, as Nadir ignores comments when it looks
  1523.                          for the next token to see if an argument list
  1524.                          exists.  This behaviour occurs because the
  1525.                          program can then easily deal with comments of any
  1526.                          length.
  1527.  
  1528.                          For Define, If, Elseif, Else and Endif, the
  1529.                          directive itself expands to nothing.  Any
  1530.                          whitespace before the keyword, back to, but not
  1531.                          including the most recent newline, is ignored.
  1532.                          Any whitespace and comments after the required
  1533.                          syntax for the keyword, up to and including the
  1534.                          first newline is dropped.  The intention is to
  1535.                          drop complete lines that contain these
  1536.                          directives.
  1537.  
  1538.                          When Eval and user defined words are expanded,
  1539.                          the words and the necessary syntax that goes with
  1540.                          them are replaced exactly by the value of the
  1541.                          expansion.  The whitespace before and after is
  1542.                          output exactly as in the input file.
  1543.  
  1544.                 Example  The following input, when processed
  1545.  
  1546.                          aaa Define Test1() { Print(".Test1."); } bbb
  1547.                          Define Test2() {
  1548.                              Print(".Test2.");
  1549.                          }
  1550.                          cccc Test1 dddd /* comment */ Test2 /*
  1551.                          another comment */ ( ignored arg) eeee
  1552.                          If (1)  ffff   Else  gggg  Endif  hhhh
  1553.                            If (1)  /* comment about If directive */
  1554.                          /* comment about output text */
  1555.                          this is output text
  1556.                            Else    /* comment on Else directive */
  1557.                          no possibility here
  1558.                            Endif   /* comment of Endif directive */
  1559.                          blah Eval(33+44) blah Eval {
  1560.                                 tmp1 = "24/11/1993" - "20/09/1953";
  1561.                                 return tmp1;
  1562.                               } blah
  1563.  
  1564.                          will produce the following output
  1565.  
  1566.                          aaabbb
  1567.                          cccc .Test1. dddd /* comment */ .Test2. eeee
  1568.                          ffffhhhh
  1569.                          /* comment about output text */
  1570.                          this is output text
  1571.                          blah 77 blah 14675 blah
  1572.  
  1573.  
  1574.  
  1575.         Chapter 2    Processing                                          19
  1576.  
  1577.  
  1578.  
  1579.  
  1580.         Processing the Input File in a Macro
  1581.  
  1582.                          The input file may be processed from within a
  1583.                          macro, either by processing tokens using the
  1584.                          Token intrinsic functions, or using the LineCurr
  1585.                          and LineGet functions to process by each line.
  1586.  
  1587.                          When performing lexical analysis, there is a
  1588.                          concept of the current token.  The whitespace
  1589.                          before the current token is known as the current
  1590.                          terminator.
  1591.  
  1592.                          When a macro is invoked without an argument list,
  1593.                          the current token is the token after the macro
  1594.                          name in the input file.  If the user performs
  1595.                          TokenNext or LineGet functions within the macro,
  1596.                          Nadir will continue processing at the current
  1597.                          token.
  1598.  
  1599.                          If an argument list is present, the current token
  1600.                          will be the closing right parenthesis of the
  1601.                          argument list. After invoking the macro, Nadir
  1602.                          performs automatically performs a TokenNext to
  1603.                          move to the next token.  It does this to retain
  1604.                          as many comments in the output file as possible.
  1605.                          This behaviour needs to be considered if
  1606.                          TokenNext or LineGet functions are called in a
  1607.                          macro that has an argument list.
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.         20                                           Nadir Reference Manual
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                 Example  The following file, when processed,
  1648.  
  1649.                          Define TestToken()
  1650.                          /*
  1651.                              designed to test TokenValue, TokenNext and
  1652.                          TokenType
  1653.                              reads tokens from input file until a non
  1654.                          integer is
  1655.                              found, or the word TestTokenEnd.
  1656.                              Returns the total of all the integers found.
  1657.                          */
  1658.                          {
  1659.                              while (TokenType() == "INT") {
  1660.                                  total += TokenValue();
  1661.                                  TokenNext();
  1662.                              }
  1663.                              if (TokenType() == "NAME"
  1664.                                      && TokenValue() == "TestTokenEnd")
  1665.                                  TokenNext();
  1666.                              return total;
  1667.                          }
  1668.                          TestToken 1 2 3 qwerty
  1669.                          TestToken 1 2 3 4 TestTokenEnd 5 6
  1670.                          TestToken 1 2 3 4 5
  1671.                          EndOfFile
  1672.  
  1673.                          will produce the following output.
  1674.  
  1675.                          6 qwerty
  1676.                          10 5 6
  1677.                          15
  1678.                          EndOfFile
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.         Chapter 2    Processing                                          21
  1710.  
  1711.  
  1712.  
  1713.  
  1714.         CHAPTER 3    LANGUAGE  OVERVIEW
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.                          This chapter introduces the language.  User
  1721.                          written functions are defined using the Define
  1722.                          keyword in the input file.  The term macro is
  1723.                          another name for a user written function.
  1724.  
  1725.                          When the input file is processed, the macro
  1726.                          source code is converted to an internal form, and
  1727.                          stored in symbols in the mdat symbol table.
  1728.  
  1729.                          Execution time is when an interpreter reads the
  1730.                          internal form and uses this to perform the
  1731.                          processing specified by the macro's statements.
  1732.  
  1733.         Functions
  1734.  
  1735.  
  1736.  
  1737.                          There are two types of functions, user written
  1738.                          and intrinsic.  User written functions, or
  1739.                          macros, are written using the Define keyword in
  1740.                          the Nadir input file.  Intrinsic functions are
  1741.                          written in C and are part of the Nadir executable
  1742.                          program.  Intrinsic functions may be written and
  1743.                          added to an executable program using the
  1744.                          Developer's Kit.
  1745.  
  1746.         Function Name
  1747.  
  1748.                          The function name may contain carets.
  1749.  
  1750.                          When a function name does not contain a caret,
  1751.                          Nadir searches for an intrinsic function and then
  1752.                          for a user written function in mdat.  If it is
  1753.                          not found, and a macro library was specified on
  1754.                          the command line, mlib is searched.
  1755.  
  1756.                          If a caret is present, the name component before
  1757.                          the first caret specifies the symbol table where
  1758.                          the function is read from.  The name of the
  1759.                          function in the symbol table is the function name
  1760.                          with the symbol table name and the first caret
  1761.                          removed.
  1762.  
  1763.         Arguments
  1764.  
  1765.                          Using Define, a list of arguments can be
  1766.                          specified.  The arguments in the function can
  1767.                          then be referenced by name.  The name given to an
  1768.                          argument has to be a valid lexical name.  A valid
  1769.                          name starts with an alphabetic character or the
  1770.                          underscore character, and may contain any number
  1771.                          of alphanumeric or underscore characters.
  1772.  
  1773.  
  1774.  
  1775.  
  1776.         22                                           Nadir Reference Manual
  1777.  
  1778.  
  1779.  
  1780.  
  1781.                          If a function is called, and an argument is not
  1782.                          passed, the argument value in the function will
  1783.                          be the null value.
  1784.  
  1785.         Return Value
  1786.  
  1787.                          A function always returns a result.  The return
  1788.                          statement can be used to specify the return value
  1789.                          of a function.  If a return statement if not
  1790.                          executed, the null value will be returned.
  1791.  
  1792.                 Example  The following function returns the arithmetic sum
  1793.                          of up to 8 arguments.
  1794.  
  1795.                          Define AddArgs(a, b, c, d, e, f, g, h)
  1796.                          {
  1797.                              return a + b + c + d + e + f + g + h;
  1798.                          }
  1799.  
  1800.         argv, argc
  1801.  
  1802.                          Arguments passed to a function can be accessed
  1803.                          using the argv and argc special variables.
  1804.  
  1805.                 Example  The following function returns the arithmetic sum
  1806.                          of all the arguments.
  1807.  
  1808.                          Define AddArgs()
  1809.                          {
  1810.                              for (i = 0; i < argc; i +=1)
  1811.                                  rv += argv[i];
  1812.  
  1813.                              return rv;
  1814.                          }
  1815.  
  1816.         Assigning Arguments
  1817.  
  1818.                          Inside the function, arguments may be assigned.
  1819.  
  1820.                 Example  Define Test(table)
  1821.                          {
  1822.                              if (!table)          // if value of table not
  1823.                          passed
  1824.                                  table = "univ";  // default to univ
  1825.                              .
  1826.                              .
  1827.                              .
  1828.                          }
  1829.  
  1830.         Passing by value and by reference
  1831.  
  1832.                          By default, arguments are passed by value.  In
  1833.                          this case, if an argument is modified in a
  1834.                          function, it is modified in the called function
  1835.                          and not modified in the calling function.
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.         Chapter 3    Language Overview                                   23
  1844.  
  1845.  
  1846.  
  1847.  
  1848.                          Arguments may be passed by reference using the &
  1849.                          operator in the calling function.  Any local
  1850.                          variable, argument or symbol may be passed by
  1851.                          reference.  In this case the value is modified in
  1852.                          the calling function.
  1853.  
  1854.                 Example  The following input, when processed,
  1855.  
  1856.                          Define Called(a, b)
  1857.                          {
  1858.                              Print(a, " ", b, "  before change in called
  1859.                          func\n");
  1860.                              a = 55;
  1861.                              b *= 2;
  1862.                              Print(a, " ", b, "  after change in called
  1863.                          func\n");
  1864.                          }
  1865.                          Eval
  1866.                          {
  1867.                              a = 12;
  1868.                              b = 24;
  1869.                              Print("Values of a and b\n");
  1870.                              Print(a, " ", b, "  before func call\n");
  1871.                              Called(a, &b);          // a passed by value
  1872.                                                      // b passed by
  1873.                          reference
  1874.                              Print(a, " ", b, "  after func call\n");
  1875.                          }
  1876.  
  1877.                          will produce the following output.
  1878.  
  1879.                          Values of a and b
  1880.                          12 24  before func call
  1881.                          12 24  before change in called func
  1882.                          55 48  after change in called func
  1883.                          12 48  after func call
  1884.  
  1885.  
  1886.         Variable Types
  1887.  
  1888.  
  1889.  
  1890.                          There are no declaration statements to define the
  1891.                          type of variable in Nadir.  The contents of the
  1892.                          field determines the type of a variable.  When an
  1893.                          operation is to be performed, Nadir examines the
  1894.                          contents of the operands, performs any necessary
  1895.                          conversions, and then produces a result.
  1896.  
  1897.                          The different types of variable that Nadir
  1898.                          recognizes are string, integer, float and date.
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.         24                                           Nadir Reference Manual
  1911.  
  1912.  
  1913.  
  1914.  
  1915.                Examples  In the expression "1234" + "1234.5678", the
  1916.                          operands are strings, the operator +, or
  1917.                          arithmetic addition.  Since the operands are
  1918.                          strings, Nadir sees if they contain an integer,
  1919.                          float or date.  In this case the operands are
  1920.                          recognized as an integer and a float.  Nadir will
  1921.                          convert the integer to a float, perform the
  1922.                          addition, and produce a float result.  Nadir will
  1923.                          hold the result as a float, so that if further
  1924.                          arithmetic is performed, no conversions may be
  1925.                          necessary.  If the result was printed using the
  1926.                          Print intrinsic function, the float would be
  1927.                          internally converted to a string prior to
  1928.                          printing.
  1929.  
  1930.                          Expression              Result
  1931.  
  1932.                          "" + 4                  4   (nothing plus 4)
  1933.                          "jhgjkhg" + 4           4   (same, nothing plus
  1934.                                                  4)
  1935.                          "123" + 12              135
  1936.                          "12.2" + 15             27.2
  1937.                          "14/2/1983" + 5         "19/2/1983"
  1938.                          "19/2/1983" -           5
  1939.                          "14/2/1983"
  1940.  
  1941.         String
  1942.  
  1943.                          Strings contain sequences of characters.
  1944.  
  1945.         Integer
  1946.  
  1947.                          Integers are stored internally as signed 32 bit
  1948.                          integers.  A valid integer has an optional
  1949.                          negative sign and followed by one or more digits.
  1950.  
  1951.         Float
  1952.  
  1953.                          Floats are stored internally as 8 byte double
  1954.                          precision floating point values.  This allows for
  1955.                          14 digits of accuracy.  A valid float has an
  1956.                          optional negative sign followed by one or more
  1957.                          digits with one decimal point.
  1958.  
  1959.         Date
  1960.  
  1961.                          Dates are stored internally as a 32 bit integer
  1962.                          as a number of days from a starting date.
  1963.  
  1964.                          The date format may be Australian, dd/mm/yyyy, or
  1965.                          US, mm/dd/yyyy.  A symbol in parm,
  1966.                          parm^system^date^format specifies the date format
  1967.                          on startup.  If "u" (the character u), the date
  1968.                          format is US, otherwise it is Australian.
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.         Chapter 3    Language Overview                                   25
  1978.  
  1979.  
  1980.  
  1981.  
  1982.         Null Value
  1983.  
  1984.                          The null value is a zero length string.  It is
  1985.                          used to signify nothing, and is the value
  1986.                          returned when a variable or symbol has not been
  1987.                          set.  Setting a symbol to the null value using an
  1988.                          assignment operator will delete it from the
  1989.                          symbol table.
  1990.  
  1991.         Boolean Value
  1992.  
  1993.                          Boolean values are produced by the logical
  1994.                          operators.  These include < <= > >= == != && and
  1995.                          ||.
  1996.  
  1997.                          Values need to be converted to boolean values
  1998.                          when processing if statements, evaluating &&, ||
  1999.                          and ?: operators,  and where intrinsic functions
  2000.                          specify an argument to be a boolean.
  2001.  
  2002.                          A boolean value is stored internally as an
  2003.                          integer, zero is false, a non-zero integer is
  2004.                          true.
  2005.  
  2006.                          Zero length strings, or null values have a value
  2007.                          of false.  Strings that have one or more
  2008.                          characters have a boolean value of true.
  2009.  
  2010.                          Numeric values, integers, floats, and the
  2011.                          internal representation of dates are false if
  2012.                          they are zero, otherwise they are true.
  2013.  
  2014.         Variables
  2015.  
  2016.  
  2017.  
  2018.                          In Nadir, values may be stored in function
  2019.                          arguments, local variables or in symbol tables.
  2020.  
  2021.                          When a function argument, local variable or
  2022.                          symbol that does not exist or has not been
  2023.                          defined, is referenced, the null value is
  2024.                          returned.
  2025.  
  2026.         Local Variables
  2027.  
  2028.                          Local variables are used in functions.  They are
  2029.                          only visible within the function that they are
  2030.                          used.  They may only be modified outside the
  2031.                          function that they are defined in by passing the
  2032.                          variable by reference to another function.
  2033.  
  2034.                          Local variables are defined when they are first
  2035.                          referenced.  Local variables are always
  2036.                          initialized to the null value.
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.         26                                           Nadir Reference Manual
  2045.  
  2046.  
  2047.  
  2048.  
  2049.                          The name given to a local variable has to be a
  2050.                          valid lexical name.  A valid name starts with an
  2051.                          alphabetic character of the underscore character,
  2052.                          and may contain any number of alphanumeric or
  2053.                          underscore characters.
  2054.  
  2055.         Symbol Tables
  2056.  
  2057.                          Symbol tables contain symbol names and symbol
  2058.                          values.  There are a number of system defined
  2059.                          symbol tables, univ, glob, parm, mdat, mlib,
  2060.                          data, temp.  The user may define other symbol
  2061.                          tables using the Sym family of  intrinsic
  2062.                          functions.  Symbol tables may be permanent,
  2063.                          shared, or temporary.
  2064.  
  2065.                          Symbols are stored in a symbol table in
  2066.                          alphabetic order by name.  The next and prev
  2067.                          operators may be used to scan through symbol
  2068.                          tables.
  2069.  
  2070.         Symbol Names
  2071.  
  2072.                          Symbol names are a series of lexical names with
  2073.                          caret ^ separators.  The first component
  2074.                          specifies the name of the symbol table.
  2075.  
  2076.                          univ^name^sex^m
  2077.                          glob^total^group^Qld
  2078.  
  2079.                          A symbol value is created or modified with an
  2080.                          assignment statement.
  2081.  
  2082.                          univ^name^sex^m = "Male";
  2083.                          univ^name^sex^f = "Female";
  2084.                          glob^total^group^Qld = 0;
  2085.  
  2086.                          To delete a symbol, set it to the null string.
  2087.  
  2088.                          univ^firstpass = "";
  2089.  
  2090.         Subscripting
  2091.  
  2092.                          Symbols may be subscripted by specifying a
  2093.                          subscript expression in square brackets [ and ].
  2094.                          At runtime, the expression is evaluated and the
  2095.                          name of the symbol is formed by concatenating the
  2096.                          components.
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.         Chapter 3    Language Overview                                   27
  2112.  
  2113.  
  2114.  
  2115.  
  2116.                 Example  The following input, when processed,
  2117.  
  2118.                          Eval {
  2119.                              univ^sex^m = "male";
  2120.                              univ^pers^bloggs^sex = "m";
  2121.                              univ^pers^bloggs^name = "Joe Bloggs";
  2122.                              code = "bloggs";
  2123.                              Print(univ^pers^[code]^name, " is ",
  2124.                                    univ^sex^[univ^pers^[code]^sex], "\n");
  2125.                          }
  2126.  
  2127.                          will produce the following output.
  2128.  
  2129.                          Joe Bloggs is male
  2130.  
  2131.                          By using subscripts, it is possible to create a
  2132.                          symbol name containing components that are not
  2133.                          names, but integers, floats and date types.
  2134.  
  2135.                 Example  Source Code             Remarks
  2136.  
  2137.                          univ^10^code            Invalid syntax, one of
  2138.                                                  the components is not a
  2139.                                                  name
  2140.  
  2141.                          univ^[10]^code          Valid syntax, resulting
  2142.                                                  symbol name is
  2143.                                                  univ^10^code
  2144.  
  2145.  
  2146.         Collating Sequence
  2147.  
  2148.                          Symbol names are stored in symbol tables in the
  2149.                          collating sequence order.
  2150.  
  2151.                          This order is determined by comparing the symbol
  2152.                          names.  Each component of the name, the parts
  2153.                          separated by carets, are compared in turn from
  2154.                          left to right.  The comparison of each component
  2155.                          uses the rules for Comparison Operators, as
  2156.                          defined in the Operand Conversion rules section.
  2157.                          When a component is less than the other, the name
  2158.                          that it belongs to is before the other in the
  2159.                          collating sequence.
  2160.  
  2161.                 Example  Name 20^xyz is before 100^abc because the first
  2162.                          components are both integers, and 20 is
  2163.                          numerically less than 100.
  2164.  
  2165.                          Name 100a^bc is before 20^xyz.  The first
  2166.                          components are different types, 100a being a
  2167.                          string (100a is not a valid integer), and 20, an
  2168.                          integer.  When a string is compared to an
  2169.                          integer, the integer is converted to a string,
  2170.                          and a string comparison is performed.
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.         28                                           Nadir Reference Manual
  2179.  
  2180.  
  2181.  
  2182.  
  2183.         next, prev operators
  2184.  
  2185.                          The following code uses the next operator to
  2186.                          print all symbols in the univ table.  The next
  2187.                          operator returns the next name after a symbol.
  2188.                          The name is returned without the table name.  The
  2189.                          prev operator will return the symbol name before
  2190.                          a symbol.  If there is no next or previous value,
  2191.                          the null value is returned.
  2192.  
  2193.                          name = "";
  2194.                          while (name = next(univ^[name]))
  2195.                              Print(name, " \t= ", univ^[name], "\n");
  2196.  
  2197.         Subscripting Symbol Table Names
  2198.  
  2199.                          The symbol table name may be subscripted.  The
  2200.                          following example shows a function that will list
  2201.                          all symbols in the symbol table specified by the
  2202.                          "table" argument.  When the example is processed,
  2203.                          the contents of the univ table will be output.
  2204.  
  2205.                          Define List(table) {
  2206.                              while (name = next([table]^[name]))
  2207.                                  Print(name, " \t= ", [table]^[name],
  2208.                          "\n");
  2209.                          }
  2210.                          List(univ)
  2211.  
  2212.         Subscripting Function Names
  2213.  
  2214.                          Function names can be subscripted.  The following
  2215.                          example shows how the action from a menu
  2216.                          selection may be used to branch to the required
  2217.                          function.
  2218.  
  2219.                          Eval {
  2220.                              pre = "mdat^menu^main";
  2221.                              [pre]^u = "SysUtilities";
  2222.                              [pre]^r = "SysReporting";
  2223.                              [pre]^i = "InvoiceEntry";
  2224.                              [pre]^c = "ClientMtce";
  2225.                              [pre]^e = "SysEnquiry";
  2226.                          }
  2227.                          Define HighLevelFunction()
  2228.                          {
  2229.                              .
  2230.                          /*
  2231.                              following code will call function based on
  2232.                          contents
  2233.                              of userChoice. System will error if
  2234.                          userChoice does
  2235.                              not contain "u", "r", "i", "c", or "e"
  2236.                          */
  2237.                              [mdat^menu^main^[userChoice]]();
  2238.                              .
  2239.                          }
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.         Chapter 3    Language Overview                                   29
  2246.  
  2247.  
  2248.  
  2249.  
  2250.         Databases
  2251.  
  2252.                          Databases can be kept using the symbol tables.
  2253.                          Building a database becomes a task of  choosing
  2254.                          an appropriate naming convention.  Consider a
  2255.                          database of person facts.  For this example it is
  2256.                          proposed that the code is a system generated
  2257.                          number. The dots represent repeated leading parts
  2258.                          of the symbol names.
  2259.  
  2260.                          person^[code]^gnam   = given name
  2261.                          ..............snam   = surname
  2262.                          ..............dob    = date of birth
  2263.                          ..............sex    = either "m" or "f"
  2264.  
  2265.                          Sample data for this example could be :-
  2266.  
  2267.                          person^[1]^dob  = "15/8/1963";
  2268.                          ...........gnam = "Mary";
  2269.                          ...........sex  = "f";
  2270.                          ...........snam = "Smith";
  2271.                          .......[2]^dob  = "12/2/1954";
  2272.                          ...........gnam = "Frederick";
  2273.                          ...........sex  = "m";
  2274.                          ...........snam = "Johnson";
  2275.                          .......[18]^dob  = "1/12/1968";
  2276.                          ............gnam = "Bruce";
  2277.                          ............sex  = "m";
  2278.                          ............snam = "Smith";
  2279.  
  2280.                          These symbols are examples of one to one
  2281.                          relationships, where one person can only have one
  2282.                          date of birth.  To build keys, we build symbols
  2283.                          names and set their values to "y" to indicate
  2284.                          their existence.  The following names and
  2285.                          examples are for access by surname, sex and date
  2286.                          of birth.  These are one to many relationships,
  2287.                          where any number of people could have the same
  2288.                          surname.
  2289.  
  2290.                          dob^person^[dob]^[code]       = "y";
  2291.                          sex^person^[sex]^[code]        = "y";
  2292.                          surname^person^[snam]^[code]   = "y";
  2293.  
  2294.                          Sample values for the above names could be :-
  2295.  
  2296.                          dob^person^["12/2/1954"]^[2] = "y";    // Johnson
  2297.                          ...........["15/8/1963"]^[1] = "y";    // Smith,
  2298.                          Mary
  2299.                          ...........["1/12/1968"]^[18] = "y";   // Smith,
  2300.                          Bruce
  2301.                          sex^person^["f"]^[1] = "y";            // Smith,
  2302.                          Mary
  2303.                          ...........["m"]^[2] = "y";            // Johnson
  2304.                          .................[18] = "y";           // Smith,
  2305.                          Bruce
  2306.                          surname^person^["Johnson"]^[2] = "y";
  2307.                          ...............["Smith"]^[1] = "y";    // Mary
  2308.                          .........................[18] = "y";   // Bruce
  2309.  
  2310.  
  2311.  
  2312.         30                                           Nadir Reference Manual
  2313.  
  2314.  
  2315.  
  2316.  
  2317.                          The method chosen to store the symbol names and
  2318.                          values uses a b-tree with leading key compression
  2319.                          and allows for variable length values.
  2320.  
  2321.                          By using leading key compression, the repeated
  2322.                          parts at the beginning of the symbol name are not
  2323.                          stored.  This is represented by the dots in the
  2324.                          examples above.  This behaviour will determine
  2325.                          the efficiency of the symbol naming convention
  2326.                          chosen.  The other consideration is that symbols
  2327.                          next to each other in the collating sequence will
  2328.                          tend to be stored in the same disk block.  In the
  2329.                          above example all the information for Mary Smith
  2330.                          will most likely be in the same disk block.
  2331.  
  2332.         Operand Conversion Rules
  2333.  
  2334.  
  2335.  
  2336.         Arithmetic Operators
  2337.  
  2338.                          The following table shows the results of an
  2339.                          arithmetic operation between two operands.  The
  2340.                          arithmetic operators are + - / * and %.
  2341.  
  2342.                          The divide function returns zero if the divisor
  2343.                          is zero.
  2344.  
  2345.                          The table shows the type of result and any
  2346.                          conversion that is automatically performed when
  2347.                          the expression a op b, eg a + b, is evaluated.
  2348.  
  2349.                                     String b  Integer    Date b   Float b
  2350.                                                  b
  2351.  
  2352.                          String a   Integer   Integer    Date *   Float *
  2353.                                        *         *
  2354.  
  2355.                          Integer a  Integer   Integer     Date    Float **
  2356.                                        *
  2357.  
  2358.                           Date a     Date *     Date    Integer   Date ***
  2359.  
  2360.                           Float a   Float *   Float **  Date ***   Float
  2361.  
  2362.  
  2363.                                    *  String is converted to zero
  2364.                                    **   Integer automatically converted to
  2365.                                    float.
  2366.                                    ***Float automatically converted to
  2367.                                    integer.
  2368.  
  2369.                          For dates, the internal value, a 32 bit integer
  2370.                          which represents a number of days from a starting
  2371.                          date, is used in the arithmetic operation.
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.         Chapter 3    Language Overview                                   31
  2380.  
  2381.  
  2382.  
  2383.  
  2384.                          The intention with dates is to perform date
  2385.                          arithmetic.  If you subtract 2 dates, the result
  2386.                          is an integer, the number of days between the
  2387.                          dates.  Adding an integer, a number of days, to a
  2388.                          date produces a date.
  2389.  
  2390.         Comparison Operators
  2391.  
  2392.                          When relational, equality and logical operators
  2393.                          are performed, a boolean value always results.
  2394.                          These operators are <, <=, >, >=, == and !=.
  2395.  
  2396.                          The type of comparison performed varies depending
  2397.                          on the operands.  Numerically, 2 is less than
  2398.                          100, however "2" is greater than "100" if a
  2399.                          string comparison is performed.
  2400.  
  2401.                          A string comparison is performed by comparing the
  2402.                          ascii values of each character in the strings, in
  2403.                          turn from left to right.  If one string is
  2404.                          shorter than the other, and the leading
  2405.                          characters are the same, the shorter string is
  2406.                          less than the longer string.
  2407.  
  2408.                          Integers and floats are compared using their
  2409.                          numeric values.
  2410.  
  2411.                          For dates, the internal value, a 32 bit integer
  2412.                          which represents a number of days from a starting
  2413.                          date, is used in the comparison operation.  If a
  2414.                          date is less than another date, it is an earlier
  2415.                          date.
  2416.  
  2417.                          The table shows the type of comparison performed
  2418.                          and any conversion that is automatically
  2419.                          performed when the expression a op b, eg a < b is
  2420.                          evaluated.
  2421.  
  2422.                                     String b  Integer    Date b   Float b
  2423.                                                  b
  2424.  
  2425.                          String a    String   String *  String *  String *
  2426.  
  2427.                          Integer a  String *  Integer   Integer   Float **
  2428.  
  2429.                           Date a    String *  Integer   Integer   Float **
  2430.  
  2431.                           Float a   String *  Float **  Float **   Float
  2432.  
  2433.  
  2434.                                    *  Non string value converted to
  2435.                                    string
  2436.                                    ** Integer or date is converted to a
  2437.                                    float.
  2438.  
  2439.                 Example  If a string is compared to a float, the float is
  2440.                          converted to a string, and a string comparison is
  2441.                          performed.
  2442.  
  2443.  
  2444.  
  2445.  
  2446.         32                                           Nadir Reference Manual
  2447.  
  2448.  
  2449.  
  2450.  
  2451.                          If a float is compared to an integer, the integer
  2452.                          is converted to a float, and a float comparison
  2453.                          is performed.
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.         Chapter 3    Language Overview                                   33
  2514.  
  2515.  
  2516.  
  2517.  
  2518.         CHAPTER 4    EXPRESSIONS
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.                          An expression is a sequence of operators and
  2525.                          operands that performs a calculation.  The
  2526.                          precedence of the operators specify the order of
  2527.                          evaluation.  During evaluation, Nadir may
  2528.                          automatically perform conversions.
  2529.  
  2530.         Operators
  2531.  
  2532.  
  2533.  
  2534.                          The following operators are available in
  2535.                          expressions.
  2536.  
  2537.                          Operator
  2538.  
  2539.                          []        Array subscript
  2540.                          ()        Function call, Evaluate
  2541.                                    expression
  2542.                          !         Logical negation (not)
  2543.                          -         Unary minus
  2544.                          &         Pass by reference
  2545.                          next      Next symbol in table
  2546.                          prev      Previous symbol in
  2547.                                    table
  2548.                          *         Multiply
  2549.                          /         Divide
  2550.                          %         Modulus (remainder)
  2551.                          +         Plus (addition)
  2552.                          -         Minus (subtraction)
  2553.                          .         Concatenation
  2554.                          <         Less than
  2555.                          <=        Less than or equal to
  2556.                          >         Greater than
  2557.                          >=        Greater than or equal
  2558.                                    to
  2559.                          ==        Equal to
  2560.                          !=        Not equal to
  2561.                          &&        Logical AND
  2562.                          ||        Logical OR
  2563.                          ?:        Conditional
  2564.                          =         Assign
  2565.                          *=        Assign product
  2566.                          /=        Assign quotent
  2567.                          %=        Assign modulus
  2568.                          +=        Assign sum
  2569.                          -=        Assign difference
  2570.                          .=        Assign concatenation
  2571.                          ,         Comma
  2572.                          ><        Alternative comma
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.         34                                           Nadir Reference Manual
  2581.  
  2582.  
  2583.  
  2584.  
  2585.         >< Operator
  2586.  
  2587.                          >< is an alternative to the comma.  It is treated
  2588.                          internally as a comma.  The following shows an
  2589.                          example of its use.  The intention is to
  2590.                          highlight, where the use of a comma may confuse.
  2591.  
  2592.                          Define DosCharFieldDefine(title, name, row,
  2593.                          value)
  2594.                          {
  2595.                              Print(
  2596.                          `  `><name><`ch = parm^screen^char^`><value><`;
  2597.                              SdPrompt(scr, `><row><`, 7, "`><title><`");
  2598.                              SdPrompt(scr, `><row><`,23, ":");
  2599.                              SdCombo(scr, "`><name><`ch", 1, `><row><`,
  2600.                          25, 6, 20,
  2601.                                           &`><name><`ch, "temp^ch^");
  2602.                          `);
  2603.                          }
  2604.  
  2605.         Operator Precedence
  2606.  
  2607.  
  2608.  
  2609.                          The following table shows the precedence of the
  2610.                          operators, from the highest first to the lowest.
  2611.  
  2612.                          () []
  2613.                          ! - & next prev
  2614.                          * / %
  2615.                          + - .
  2616.                          < <= > >=
  2617.                          == !=
  2618.                          &&
  2619.                          ||
  2620.                          ?:
  2621.                          = *= /= %= += -=
  2622.                          , ><
  2623.  
  2624.         Expression Syntax
  2625.  
  2626.  
  2627.  
  2628.                          The formal syntax of an expression follows.  Each
  2629.                          of the elements will be described in detail in
  2630.                          later sections.
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.         Chapter 4    Expressions                                         35
  2648.  
  2649.  
  2650.  
  2651.  
  2652.                          primary-expression:
  2653.                               lvalue
  2654.                               function-name ( <argument-list> )
  2655.                               subscript-list ( <argument-list> )
  2656.                               argc
  2657.                               string-constant
  2658.                               integer-constant
  2659.                               float-constant
  2660.                               date-constant
  2661.                               next ( symbol )
  2662.                               prev ( symbol )
  2663.                               ! primary-expression
  2664.                               - primary-expression
  2665.                               ( expression )
  2666.  
  2667.                          symbol:
  2668.                               symbol-table-name ^ <subscript-list>
  2669.                               subscript-list
  2670.  
  2671.                          lvalue:
  2672.                               symbol
  2673.                               argv [ expression ]
  2674.                               argument-name
  2675.                               local-variable-name
  2676.  
  2677.                          function-name:
  2678.                               name
  2679.                               function-name ^ <name>
  2680.  
  2681.                          subscript-list
  2682.                               name
  2683.                               <subscript-list> ^ <name>
  2684.                               <subscript-list> [ expression ]
  2685.  
  2686.                          argument:
  2687.                               assignment-expression
  2688.                               & lvalue
  2689.  
  2690.                          argument-list:
  2691.                               argument
  2692.                               <argument-list> , <argument>
  2693.  
  2694.                          multiplicative-expression:
  2695.                               primary-expression
  2696.                               primary-expression * multiplicative-
  2697.                          expression
  2698.                               primary-expression / multiplicative-
  2699.                          expression
  2700.                               primary-expression % multiplicative-
  2701.                          expression
  2702.  
  2703.                          additive-expression:
  2704.                               multiplicative-expression
  2705.                               multiplicative-expression + additive-
  2706.                          expression
  2707.                               multiplicative-expression - additive-
  2708.                          expression
  2709.                               multiplicative-expression . additive-
  2710.                          expression
  2711.  
  2712.  
  2713.  
  2714.         36                                           Nadir Reference Manual
  2715.  
  2716.  
  2717.  
  2718.  
  2719.                          relational-expression:
  2720.                               addition-expression
  2721.                               addition-expression < relational-expression
  2722.                               addition-expression <= relational-expression
  2723.                               addition-expression > relational-expression
  2724.                               addition-expression >= relational-expression
  2725.  
  2726.                          equality-expression:
  2727.                               relational-expression
  2728.                               relational-expression == equality-expression
  2729.                               relational-expression != equality-expression
  2730.  
  2731.                          logical-and-expression:
  2732.                               equality-expression
  2733.                               equality-expression && logical-and-
  2734.                          expression
  2735.  
  2736.                          logical-or-expression:
  2737.                               logical-and-expression
  2738.                               logical-and-expression || logical-or-
  2739.                          expression
  2740.  
  2741.                          conditional-expression:
  2742.                               logical-or-expression
  2743.                               logical-or-expression ? expression
  2744.                                                   : conditional-expression
  2745.  
  2746.                          assignment-expression:
  2747.                               conditional-expression
  2748.                               lvalue = assignment-expression
  2749.                               lvalue *= assignment-expression
  2750.                               lvalue /= assignment-expression
  2751.                               lvalue %= assignment-expression
  2752.                               lvalue += assignment-expression
  2753.                               lvalue -= assignment-expression
  2754.                               lvalue .= assignment-expression
  2755.  
  2756.                          expression:
  2757.                               assignment-expression
  2758.                               expression , assignment-expression
  2759.  
  2760.         Primary Expression
  2761.  
  2762.  
  2763.  
  2764.                          primary-expression:
  2765.                               lvalue
  2766.                               function-name ( <argument-list> )
  2767.                               subscript-list ( <argument-list> )
  2768.                               argc
  2769.                               string-constant
  2770.                               integer-constant
  2771.                               float-constant
  2772.                               date-constant
  2773.                               next ( symbol )
  2774.                               prev ( symbol )
  2775.                               ! primary-expression
  2776.                               - primary-expression
  2777.                               ( expression )
  2778.  
  2779.  
  2780.  
  2781.         Chapter 4    Expressions                                         37
  2782.  
  2783.  
  2784.  
  2785.  
  2786.         Lvalue
  2787.  
  2788.                          An lvalue is the term given to an object that may
  2789.                          be specified on the left hand side of an
  2790.                          assignment expression.
  2791.  
  2792.                          lvalue:
  2793.                               symbol
  2794.                               argv [ expression ]
  2795.                               argument-name
  2796.                               local-variable-name
  2797.  
  2798.                    argv  argv is a special type of variable that allows
  2799.                          one of a macro's arguments to be referenced using
  2800.                          an ordinal value.  The expression after argv is
  2801.                          converted an integer and defines which argument
  2802.                          is to be used.  If zero, the first argument is
  2803.                          referenced, if one, the second argument is
  2804.                          referenced, and so on.  If the expression is
  2805.                          greater than or equal to the number of arguments
  2806.                          passed, the null value is returned.
  2807.  
  2808.                          The other options for lvalue specify either an
  2809.                          argument, a local variable or a symbol name.  If
  2810.                          the name does not contain a caret, or subscripts,
  2811.                          the name will be an argument or a local variable.
  2812.                          It is an argument if the name is in the arg-name-
  2813.                          list specified with the Define keyword.
  2814.  
  2815.         Symbol
  2816.  
  2817.                          A symbol is an item that is stored in a symbol
  2818.                          table.  It has the following syntax.
  2819.  
  2820.                          symbol:
  2821.                               symbol-table-name ^ <subscript-list>
  2822.                               subscript-list
  2823.  
  2824.                          For symbol names, the name may start with a
  2825.                          symbol table name followed by a caret and a
  2826.                          subscript list, or may be a subscript list where
  2827.                          the symbol table name is subscripted.
  2828.  
  2829.                          The symbol table name may be a system defined
  2830.                          table, univ, glob, parm, mdat, mlib, data, temp,
  2831.                          or a user defined name.  See SymOpen or SymCreate
  2832.                          intrinsic functions.
  2833.  
  2834.          subscript-list  A subscript-list has the following syntax.
  2835.  
  2836.                          subscript-list
  2837.                               name
  2838.                               <subscript-list> ^ <name>
  2839.                               <subscript-list> [ expression ]
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.         38                                           Nadir Reference Manual
  2849.  
  2850.  
  2851.  
  2852.  
  2853.                          The intention is that a subscript-list can be any
  2854.                          combination of caret, names and expressions in
  2855.                          brackets [].  Two names cannot appear next to
  2856.                          each other, and a symbol cannot contain a single
  2857.                          name.
  2858.  
  2859.                          Subscripting allows the actual name of the symbol
  2860.                          to be evaluated, by concatenating the components
  2861.                          together.  When a symbol name is evaluated, it
  2862.                          must contain at least one caret, the component
  2863.                          before the first caret specifying the name of the
  2864.                          symbol table.
  2865.  
  2866.         Function Call
  2867.  
  2868.                          A function call is specified when a name or
  2869.                          subscript-list is followed by parenthesis
  2870.                          enclosing an optional argument list.
  2871.  
  2872.                               function-name ( <argument-list> )
  2873.                               subscript-list ( <argument-list> )
  2874.  
  2875.                          The function name specifies an intrinsic function
  2876.                          built into the Nadir executable using the
  2877.                          Developer's Kit, or a user defined function
  2878.                          created by processing the Define keyword.
  2879.  
  2880.                          The function name may contain carets.
  2881.  
  2882.                          If a function name does not contain a caret,
  2883.                          Nadir searches for an intrinsic function and then
  2884.                          for a user written function in mdat.  If it is
  2885.                          not found, and a macro library was specified on
  2886.                          the command line, mlib is searched.
  2887.  
  2888.                          If a caret is present in the function name, the
  2889.                          name component before the first caret specifies
  2890.                          the symbol table where the function is read from.
  2891.                          The name of the function in the symbol table is
  2892.                          the function name with the symbol table name and
  2893.                          the first caret removed.
  2894.  
  2895.                          When the subscript list alternative is used, the
  2896.                          subscript-list is evaluated at execution time to
  2897.                          provide the name of the function to call.  The
  2898.                          name evaluated may be an intrinsic function or a
  2899.                          user defined function.
  2900.  
  2901.                          At execution time, if a function is not found, an
  2902.                          error is signalled.
  2903.  
  2904.                          A function call always evaluates to a value.  If
  2905.                          the called function executes a return statement,
  2906.                          it is the value of the return expression,
  2907.                          otherwise it is the null value.
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.         Chapter 4    Expressions                                         39
  2916.  
  2917.  
  2918.  
  2919.  
  2920.           Argument List  Arguments may be passed to a function.  The
  2921.                          argument list contains optional arguments
  2922.                          separated by commas.
  2923.  
  2924.                          argument:
  2925.                               assignment-expression
  2926.                               & lvalue
  2927.  
  2928.                          argument-list:
  2929.                               argument
  2930.                               <argument-list> , <argument>
  2931.  
  2932.                          An argument may be either an assignment
  2933.                          expression, or an & followed by an lvalue.  When
  2934.                          the & is used, the lvalue is passed by reference.
  2935.                          When a variable is passed by reference, the
  2936.                          called function may modify the value or contents
  2937.                          of the variable.  Symbol names, local names, or
  2938.                          argument names may be passed by reference.
  2939.  
  2940.                          If the assignment expression form is used, the
  2941.                          value is passed.
  2942.  
  2943.                          If the argument is not specified, the null value
  2944.                          is assumed.  The following table shows some valid
  2945.                          argument lists.
  2946.  
  2947.                          Argument     Remarks
  2948.                          List
  2949.  
  2950.                          ()           no arguments
  2951.                          (a)          1 argument
  2952.                          (,)          2 null arguments
  2953.                          (b,)         2 arguments, last one
  2954.                                       null
  2955.                          (a,b)        2 arguments
  2956.                          (,b)         2 arguments, first
  2957.                                       one null
  2958.  
  2959.         argc
  2960.  
  2961.                          argc is a special word that returns the number of
  2962.                          arguments passed to the function that it occurs
  2963.                          in.
  2964.  
  2965.         next
  2966.  
  2967.                          The next operator is used to find the next symbol
  2968.                          in a symbol table.
  2969.  
  2970.                               next ( lvalue )
  2971.  
  2972.                          The lvalue must specifiy a symbol name.  If it is
  2973.                          a subscript list, the evaluated name must contain
  2974.                          a caret with the first element of the name
  2975.                          specifying a valid symbol table.
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.         40                                           Nadir Reference Manual
  2983.  
  2984.  
  2985.  
  2986.  
  2987.                          The return value is a string containing the next
  2988.                          name after the lvalue.  The return value of next
  2989.                          does not include the symbol table name.  If
  2990.                          lvalue is the last symbol in the table, the null
  2991.                          value is returned.
  2992.  
  2993.                          See the example of next in Subscripting Symbol
  2994.                          Table Names in the Language Overview chapter.
  2995.  
  2996.         prev
  2997.  
  2998.                          The prev operator is used to find the previous
  2999.                          symbol in a symbol table.
  3000.  
  3001.                               prev ( lvalue )
  3002.  
  3003.                          The lvalue must specifiy a symbol name.  If it is
  3004.                          a subscript list, the evaluated name must contain
  3005.                          a caret, with the first element of the name
  3006.                          specifying a valid symbol table.
  3007.  
  3008.                          The return value is a string containing the
  3009.                          previous name before the lvalue.  The return
  3010.                          value of prev does not include the symbol table
  3011.                          name.  If lvalue is the first symbol in the
  3012.                          table, the null value is returned.
  3013.  
  3014.         Logical negation !
  3015.  
  3016.                          The ! unary operator returns the logical negation
  3017.                          of the operand, the following primary expression.
  3018.  
  3019.                               ! primary-expression
  3020.  
  3021.                          The result is a boolean value.  The primary-
  3022.                          expression is converted to a boolean, and then a
  3023.                          logical negation is performed.  i.e. True becomes
  3024.                          false, false becomes true.
  3025.  
  3026.         Unary minus -
  3027.  
  3028.                          The unary minus operator returns the negative of
  3029.                          the operand.
  3030.  
  3031.                               - primary-expression
  3032.  
  3033.                          If the primary expression is not an integer,
  3034.                          float or date, zero is returned.
  3035.  
  3036.         Parenthesis
  3037.  
  3038.                          Parenthesis () may be used to override the
  3039.                          precedence of an operator, or to change the order
  3040.                          of evaluation.  The following table shows some
  3041.                          examples.
  3042.  
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.         Chapter 4    Expressions                                         41
  3050.  
  3051.  
  3052.  
  3053.  
  3054.                          Expression        Evaluation Steps
  3055.  
  3056.                          a + b * c         b multiplied by c, then added
  3057.                                            to a
  3058.                          (a + b) * c       b added to a, then multiplied
  3059.                                            by c
  3060.                          a + b + c         b added to a, then c added.
  3061.                          a + (b + c)       c added to b, which is added to
  3062.                                            a
  3063.  
  3064.         Multiplicative Expression
  3065.  
  3066.  
  3067.  
  3068.                          The three multiplicative operators are * / and %.
  3069.  
  3070.                          multiplicative-expression:
  3071.                               primary-expression
  3072.                               primary-expression * multiplicative-
  3073.                          expression
  3074.                               primary-expression / multiplicative-
  3075.                          expression
  3076.                               primary-expression % multiplicative-
  3077.                          expression
  3078.  
  3079.                          The operands are converted using the arithmetic
  3080.                          conversion rules for arithmetic operators.
  3081.  
  3082.                          The * operator produces the product of the two
  3083.                          operands.
  3084.  
  3085.                          The / operator produces the quotent when the
  3086.                          first operand is divided by the second operand.
  3087.                          If the second operand is zero, the result will be
  3088.                          zero.
  3089.  
  3090.                          The % or modulus operator produces the remainder
  3091.                          when the first operand is divided by the second
  3092.                          operand.  If the second operand is zero, the
  3093.                          result will be zero.  If the operands are floats,
  3094.                          x % y is the remainder f, where x = ay + f for
  3095.                          some integer a and 0 <= f < y.  eg 5.0 % 2.0 is
  3096.                          1.0
  3097.  
  3098.         Additive Expression
  3099.  
  3100.  
  3101.  
  3102.                          The three additive operators are + , - and ., the
  3103.                          fullstop.
  3104.  
  3105.                          additive-expression:
  3106.                               multiplicative-expression
  3107.                               multiplicative-expression + additive-
  3108.                          expression
  3109.                               multiplicative-expression - additive-
  3110.                          expression
  3111.                               multiplicative-expression . additive-
  3112.                          expression
  3113.  
  3114.  
  3115.  
  3116.         42                                           Nadir Reference Manual
  3117.  
  3118.  
  3119.  
  3120.  
  3121.                          For + and -, The operands are converted using the
  3122.                          arithmetic conversion rules for arithmetic
  3123.                          operators.
  3124.  
  3125.                          The + operator produces the sum of the two
  3126.                          operands.
  3127.  
  3128.                          The - operator produces the difference, when the
  3129.                          second operand is subtracted from the first.
  3130.  
  3131.                          The . operator converts the operands to strings,
  3132.                          if necessary, and concatenates them, forming a
  3133.                          string result.
  3134.  
  3135.         Relational Expression
  3136.  
  3137.  
  3138.  
  3139.                          The four relational operators are <, <=, >, >=
  3140.  
  3141.                          relational-expression:
  3142.                               additive-expression
  3143.                               additive-expression < relational-expression
  3144.                               additive-expression <= relational-expression
  3145.                               additive-expression > relational-expression
  3146.                               additive-expression >= relational-expression
  3147.  
  3148.                          The operands are converted using the arithmetic
  3149.                          conversion rules for comparison operators.  The
  3150.                          type of comparision performed depends on what
  3151.                          types the operands are converted to.
  3152.  
  3153.                          The result of a relational operator is a boolean
  3154.                          value.
  3155.  
  3156.                          The operators are described in the following
  3157.                          table.
  3158.  
  3159.                          a < b     if a is less than b, true is
  3160.                                    returned, else false is returned.
  3161.  
  3162.                          a <= b    if a is less than or equal to  b,
  3163.                                    true is returned, else false is
  3164.                                    returned.
  3165.  
  3166.                          a > b     if a is greater than b, true is
  3167.                                    returned, else false is returned.
  3168.  
  3169.                          a >= b    if a is greater than or equal to
  3170.                                    b, true is returned, else false
  3171.                                    is returned.
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.         Chapter 4    Expressions                                         43
  3184.  
  3185.  
  3186.  
  3187.  
  3188.         Equality Expression
  3189.  
  3190.  
  3191.  
  3192.                          The two equality operators are == and !=.  These
  3193.                          have a lower precedence than the relational
  3194.                          operators.
  3195.  
  3196.                          equality-expression:
  3197.                               relational-expression
  3198.                               relational-expression == equality-expression
  3199.                               relational-expression != equality-expression
  3200.  
  3201.                          The operands are converted using the arithmetic
  3202.                          conversion rules for comparison operators.  The
  3203.                          type of comparision performed depends on what
  3204.                          types the operands are converted to.
  3205.  
  3206.                          The result of an equality operator is a boolean
  3207.                          value.
  3208.  
  3209.                          The operators are described in the following
  3210.                          table.
  3211.  
  3212.                          a == b    if a is equal to b, true is
  3213.                                    returned, else false is returned.
  3214.  
  3215.                          a != b    if a is not equal to  b, true is
  3216.                                    returned, else false is returned.
  3217.  
  3218.         Logical And Expression
  3219.  
  3220.  
  3221.  
  3222.                          logical-and-expression:
  3223.                               equality-expression
  3224.                               equality-expression && logical-and-
  3225.                          expression
  3226.  
  3227.                          The logical and operator is &&.  The result is a
  3228.                          boolean value, true if both operands are true,
  3229.                          otherwise the result is false.  An operand is
  3230.                          converted to a boolean value when the test for
  3231.                          true is performed.
  3232.  
  3233.                          If the first operand is false, the second operand
  3234.                          will not be evaluated, and false will be the
  3235.                          result.
  3236.  
  3237.         Logical Or Expression
  3238.  
  3239.  
  3240.  
  3241.                          logical-or-expression:
  3242.                               logical-and-expression
  3243.                               logical-and-expression || logical-or-
  3244.                          expression
  3245.  
  3246.  
  3247.  
  3248.  
  3249.  
  3250.         44                                           Nadir Reference Manual
  3251.  
  3252.  
  3253.  
  3254.  
  3255.                          The logical or operator is ||and has a lower
  3256.                          precedence than logical and, &&.  The result is a
  3257.                          boolean value, true if either of the operands are
  3258.                          true, otherwise the result is false.  An operand
  3259.                          is converted to a boolean value when the test for
  3260.                          true is performed.
  3261.  
  3262.                          If the first operand is true, the second operand
  3263.                          will not be evaluated, and true will be the
  3264.                          result.
  3265.  
  3266.         Conditional Expression
  3267.  
  3268.  
  3269.  
  3270.                          conditional-expression:
  3271.                               logical-or-expression
  3272.                               logical-or-expression ? expression
  3273.                                                   : conditional-expression
  3274.  
  3275.                          In the expression a ? b : c, a is evaluated, and
  3276.                          converted to a boolean value.  If the value of a
  3277.                          is true, expression b is evaluated, and is the
  3278.                          result of the conditional expression.  If a is
  3279.                          false, expression c is evaluated, which becomes
  3280.                          the result of the conditional expression.
  3281.  
  3282.         Assignment Expression
  3283.  
  3284.  
  3285.  
  3286.                          assignment-expression:
  3287.                               conditional-expression
  3288.                               lvalue = assignment-expression
  3289.                               lvalue *= assignment-expression
  3290.                               lvalue /= assignment-expression
  3291.                               lvalue %= assignment-expression
  3292.                               lvalue += assignment-expression
  3293.                               lvalue -= assignment-expression
  3294.                               lvalue .= assignment-expression
  3295.  
  3296.                          The assignment expressions are used to assign a
  3297.                          value to the argument, variable or symbol
  3298.                          specified by the lvalue operand.
  3299.  
  3300.                          When the assignment operator = expression is
  3301.                          evaluated, the assignment-expression is
  3302.                          evaluated, and is stored in the variable
  3303.                          specified by the lvalue.  The result of the
  3304.                          expression is the value of the lvalue after the
  3305.                          assignment.
  3306.  
  3307.                          The other assignment operators are *=, /=, %=,
  3308.                          +=, -= and .=.  Each of these are an arithmetic
  3309.                          operator followed by an equals sign.
  3310.  
  3311.                          a op= b has the same result as a = a op b.
  3312.  
  3313.  
  3314.  
  3315.  
  3316.  
  3317.         Chapter 4    Expressions                                         45
  3318.  
  3319.  
  3320.  
  3321.  
  3322.         Expression
  3323.  
  3324.  
  3325.  
  3326.                          expression:
  3327.                               assignment-expression
  3328.                               expression , assignment-expression
  3329.  
  3330.                          The lowest precedence operator is the comma
  3331.                          operator.
  3332.  
  3333.                          An expression is a list of one or more
  3334.                          assignment-expressions, separated by the comma
  3335.                          operator.  Each of the assignment-expressions are
  3336.                          evaluated, starting from the left, and proceeding
  3337.                          to the right.  The result of the expression is
  3338.                          the result of the last assignment-expression.
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.  
  3376.  
  3377.  
  3378.  
  3379.  
  3380.  
  3381.  
  3382.  
  3383.  
  3384.         46                                           Nadir Reference Manual
  3385.  
  3386.  
  3387.  
  3388.  
  3389.         CHAPTER 5    STATEMENTS
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.                          The Define keyword in the input file is used to
  3396.                          define a user written function, sometimes
  3397.                          referred to as a macro.  The syntax of the Define
  3398.                          keyword includes a compound statement.  This
  3399.                          compound statement specifies the processing to be
  3400.                          performed by the function.  The compound
  3401.                          statement may contain a number of statements,
  3402.                          performed in the order written.
  3403.  
  3404.                          The syntax of the statements follow.  Each of the
  3405.                          statements are described in detail later in this
  3406.                          chapter.
  3407.  
  3408.                          statement:
  3409.                               compound-statement
  3410.                               label-statement
  3411.                               null-statement
  3412.                               expression-statement
  3413.                               return-statement
  3414.                               if-statement
  3415.                               while-statement
  3416.                               do-statement
  3417.                               for-statement
  3418.                               switch-statement
  3419.                               case-statement
  3420.                               default-statement
  3421.                               break-statement
  3422.                               continue-statement
  3423.                               goto-statement
  3424.  
  3425.                          compound-statement:
  3426.                               { <statement-list> }
  3427.  
  3428.                          statement-list:
  3429.                               statement
  3430.                               statement-list statement
  3431.  
  3432.                          label-statement:
  3433.                               label-name : <statement>
  3434.  
  3435.                          null-statement:
  3436.                               ;
  3437.  
  3438.                          expression-statement:
  3439.                               expression ;
  3440.  
  3441.                          return-statement:
  3442.                               return <expression> ;
  3443.  
  3444.                          if-statement:
  3445.                               if ( expression ) statement <else statement>
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.         Chapter 5    Statements                                          47
  3452.  
  3453.  
  3454.  
  3455.  
  3456.                          while-statement:
  3457.                               while ( expression ) statement
  3458.  
  3459.                          do-statement:
  3460.                               do statement while ( expression ) ;
  3461.  
  3462.                          for-statement:
  3463.                               for ( <expression> ; <expression> ;
  3464.                          <expression> )      statement
  3465.  
  3466.                          switch-statement:
  3467.                               switch ( expression ) statement
  3468.  
  3469.                          case-statement:
  3470.                               case expression : statement
  3471.  
  3472.                          default-statement:
  3473.                               default : statement
  3474.  
  3475.                          break-statement:
  3476.                               break ;
  3477.  
  3478.                          continue-statement:
  3479.                               continue ;
  3480.  
  3481.                          goto-statement:
  3482.                               goto label-name
  3483.  
  3484.         Compound Statement
  3485.  
  3486.  
  3487.  
  3488.                          compound-statement:
  3489.                               { <statement-list> }
  3490.  
  3491.                          statement-list:
  3492.                               statement
  3493.                               statement-list statement
  3494.  
  3495.                          A compound statement is an optional list of
  3496.                          statements enclosed in matching braces {}.
  3497.  
  3498.                          Syntactically, a compound statement is treated as
  3499.                          a statement.  For example, in the while
  3500.                          statement, a statement is required.  A compound
  3501.                          statement is used in this case where the body of
  3502.                          the while loop contains a number of  statements.
  3503.  
  3504.                          A compound statement is used to define the
  3505.                          processing to be performed by a function in the
  3506.                          Define keyword.
  3507.  
  3508.         Label Statement
  3509.  
  3510.  
  3511.  
  3512.                          label-statement:
  3513.                               label-name : <statement>
  3514.  
  3515.  
  3516.  
  3517.  
  3518.         48                                           Nadir Reference Manual
  3519.  
  3520.  
  3521.  
  3522.  
  3523.                          A statement may be labelled by using a label
  3524.                          followed by a colon.  A label-name is a valid
  3525.                          lexical name.  The same label name may not be
  3526.                          used more than once in a function definition.
  3527.  
  3528.                          The label-name may then be used as the target of
  3529.                          the goto statement but only within the function
  3530.                          that it is defined in.
  3531.  
  3532.         Null Statement
  3533.  
  3534.  
  3535.  
  3536.                          null-statement:
  3537.                               ;
  3538.  
  3539.                          The null statement consists of a semi-colon.  It
  3540.                          does nothing and is used in situations where the
  3541.                          syntax of a statement requires a statement, but
  3542.                          no processing is necessary.
  3543.  
  3544.         Expression Statement
  3545.  
  3546.  
  3547.  
  3548.                          expression-statement:
  3549.                               expression ;
  3550.  
  3551.                          An expression statement is an expression followed
  3552.                          by a semicolon.  The expression is evaluated, and
  3553.                          control passed to the next statement.
  3554.  
  3555.         Return Statement
  3556.  
  3557.  
  3558.  
  3559.                          return-statement:
  3560.                               return <expression> ;
  3561.  
  3562.                          The return statement is used to pass control from
  3563.                          a function to the calling function.
  3564.  
  3565.                          If the optional expression is present, it is
  3566.                          evaluted, and the result becomes the return value
  3567.                          for the function.
  3568.  
  3569.                          If there is no expression, the null value is
  3570.                          returned.
  3571.  
  3572.                          If a function does not have a return statement,
  3573.                          return is made after the last statement in the
  3574.                          function is executed.  The null value is
  3575.                          returned.
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.         Chapter 5    Statements                                          49
  3586.  
  3587.  
  3588.  
  3589.  
  3590.         If Statement
  3591.  
  3592.  
  3593.  
  3594.                          if-statement:
  3595.                               if ( expression ) statement1 <else
  3596.                          statement2>
  3597.  
  3598.                          The if statement allows conditional processing
  3599.                          based on the result of an expression.
  3600.  
  3601.                          The expression is evaluated, and the result is
  3602.                          converted to a boolean value.  If the value is
  3603.                          true, statement1 is executed.  If the value is
  3604.                          false, and the optional else statement2 is
  3605.                          present, statement2 is executed.
  3606.  
  3607.         While Statement
  3608.  
  3609.  
  3610.  
  3611.                          while-statement:
  3612.                               while ( expression ) statement
  3613.  
  3614.                          The while statement is a pre tested loop
  3615.                          statement.
  3616.  
  3617.                          The expression is evaluated and converted to a
  3618.                          boolean value.  If the value is true, the
  3619.                          statement is executed.  If there are no
  3620.                          statements that pass control out of the loop, the
  3621.                          expression is evaluated again.  The loop
  3622.                          continues until the expression evaluates to
  3623.                          false.  When this occurs, contol is passed to the
  3624.                          statement after the while statement.
  3625.  
  3626.         Do Statement
  3627.  
  3628.  
  3629.  
  3630.                          do-statement:
  3631.                               do statement while ( expression ) ;
  3632.  
  3633.                          The do statement is a post-tested loop statement.
  3634.  
  3635.                          The statement is executed.  If there are no
  3636.                          statements that pass control out of the loop, the
  3637.                          expression is then evaluated and converted to a
  3638.                          boolean value.  If the value is true, control
  3639.                          passed to the beginning of the statement, and the
  3640.                          statement is then executed again.  If the value
  3641.                          is false, control is passed to the next
  3642.                          statement.
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.         50                                           Nadir Reference Manual
  3653.  
  3654.  
  3655.  
  3656.  
  3657.         For Statement
  3658.  
  3659.  
  3660.  
  3661.                          for-statement:
  3662.                               for ( <expression1> ; <expression2> ;
  3663.                          <expression3> )          loop-statement
  3664.  
  3665.                          The for statement is pre-tested loop statement.
  3666.  
  3667.                          expression1 is the initializing expression.  If
  3668.                          it is present, it is executed.
  3669.  
  3670.                          expression2 is the test expression.  If present,
  3671.                          it is evaluated and converted to a boolean value.
  3672.                          If it is not present, a true value is assumed.
  3673.                          If the value is true, the loop-statement is
  3674.                          executed.
  3675.  
  3676.                          expression3 is the increment expression.  After
  3677.                          the loop-statement is executed, the increment
  3678.                          expression, if present, is evaluated.
  3679.  
  3680.                          Control is then passed back to the step where the
  3681.                          test expression is evaluated and tested.
  3682.  
  3683.         Switch, Case and Default Statements
  3684.  
  3685.  
  3686.  
  3687.                          switch-statement:
  3688.                               switch ( expression1 ) statement1
  3689.  
  3690.                          case-statement:
  3691.                               case expression : statement2
  3692.  
  3693.                          default-statement:
  3694.                               default : statement3
  3695.  
  3696.                          The switch statement allows branching to sections
  3697.                          of code marked by case or default statements,
  3698.                          based on the value of the switch expression.
  3699.  
  3700.                          In statement1 there can optionally be one default
  3701.                          statement, and any number of case statements.
  3702.  
  3703.                          expression1 is evaluated.  It is then tested for
  3704.                          equality with each of the expressions in any case
  3705.                          statements.  These expressions are evaluated in
  3706.                          the order they occur in statement1.  When
  3707.                          equality is found, statement2 in the case
  3708.                          statement is executed.  Execution then continues
  3709.                          until the end of statement1.  Any case
  3710.                          expressions encountered are not evaluated, but
  3711.                          any statement2 in following case statements or a
  3712.                          statement3 will be executed.
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.         Chapter 5    Statements                                          51
  3720.  
  3721.  
  3722.  
  3723.  
  3724.                          To stop execution after a statement2 in a case
  3725.                          statement, the break statement may be used to
  3726.                          transfer control to after statement1.
  3727.  
  3728.                          If no equality is found with case expressions,
  3729.                          and there is a default statement, control passes
  3730.                          to the statement3.  If there is no default
  3731.                          statement, control passes to the end of
  3732.                          statement1.
  3733.  
  3734.         Break Statement
  3735.  
  3736.  
  3737.  
  3738.                          break-statement:
  3739.                               break ;
  3740.  
  3741.                          A break can only be used within a while, do or
  3742.                          for loop, or a switch statement.
  3743.  
  3744.                          It terminates the nearest enclosing loop or
  3745.                          switch statement.
  3746.  
  3747.         Continue Statement
  3748.  
  3749.  
  3750.  
  3751.                          continue-statement:
  3752.                               continue ;
  3753.  
  3754.                          A continue statement can only be used within a
  3755.                          while, do or for loop.
  3756.  
  3757.                          In while and do loops, it transfers control to
  3758.                          the test expression.
  3759.  
  3760.                          In for loops, control is passed to the increment
  3761.                          expression.
  3762.  
  3763.                          With nested loops, the continue statement belongs
  3764.                          to the nearest enclosing loop.
  3765.  
  3766.         Goto Statement
  3767.  
  3768.  
  3769.  
  3770.                          goto-statement:
  3771.                               goto label-name
  3772.  
  3773.                          The goto statement transfers contol to the
  3774.                          statement labeled with the label-name.
  3775.  
  3776.                          The label must be defined in the same function as
  3777.                          the goto statement.
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.         52                                           Nadir Reference Manual
  3787.  
  3788.  
  3789.  
  3790.  
  3791.         CHAPTER 6    SYSTEM  INTRINSIC  FUNCTIONS
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.                          This chapter details the basic set of intrinsic
  3798.                          functions that is always present in Nadir.  With
  3799.                          the Developer's Kit, other modules of intrinsic
  3800.                          functions may be added to the system.
  3801.  
  3802.         Bunch
  3803.  
  3804.  
  3805.  
  3806.                Function  Bunch a number of fields into one field.
  3807.  
  3808.                  Syntax  Bunch(arg ...)
  3809.  
  3810.                 Returns  The bunch formed by the given arguments
  3811.  
  3812.                 Remarks  This allows a number of fields to be stored in
  3813.                          one field.  A bunch may be broken into its
  3814.                          components by using the Unbunch function.
  3815.  
  3816.                 Example  l_ocal = Bunch(1, 2, 3, "abcd", 45.2);
  3817.  
  3818.                          This will store a bunch of 5 elements in the
  3819.                          local variable l_ocal.
  3820.  
  3821.         DateDay
  3822.  
  3823.  
  3824.  
  3825.                Function  Get day component of date
  3826.  
  3827.                  Syntax  DateDay(date)
  3828.  
  3829.                 Returns  The day number in the month of the date argument.
  3830.  
  3831.                 Example  DateDay("3/5/1990")
  3832.  
  3833.                          would return 3 if dd/mm/yyyy is the date format.
  3834.  
  3835.         DateDayName
  3836.  
  3837.  
  3838.  
  3839.                Function  Get day name of a date
  3840.  
  3841.                  Syntax  DateDayName(date)
  3842.  
  3843.                 Returns  The day name of the date argument.
  3844.  
  3845.                 Example  DateDayName("18/1/1993")
  3846.  
  3847.                          would return "Monday"
  3848.  
  3849.  
  3850.  
  3851.  
  3852.  
  3853.         Chapter 6    System Intrinsic Functions                          53
  3854.  
  3855.  
  3856.  
  3857.  
  3858.         DateMonth
  3859.  
  3860.  
  3861.  
  3862.                Function  Get month component of date
  3863.  
  3864.                  Syntax  DateMonth(date)
  3865.  
  3866.                 Returns  The month number of the date argument.
  3867.  
  3868.                 Example  DateMonth("3/5/1990")
  3869.  
  3870.                          would return 5 if dd/mm/yyyy is the date format.
  3871.  
  3872.         DateMonthEnd
  3873.  
  3874.  
  3875.  
  3876.                Function  Get the month end date.
  3877.  
  3878.                  Syntax  DateMonthEnd(date)
  3879.  
  3880.                 Returns  Date of the last day of the month of the date
  3881.                          argument.
  3882.  
  3883.                 Example  DateMonthEnd("3/5/1990")
  3884.  
  3885.                          would return "31/5/1990".  Note that the value
  3886.                          returned is really a date, not a string.
  3887.  
  3888.         DateMonthName
  3889.  
  3890.  
  3891.  
  3892.                Function  Get month name of a date
  3893.  
  3894.                  Syntax  DateMonthName(date)
  3895.  
  3896.                 Returns  The month name of the date argument.
  3897.  
  3898.                 Example  DateMonthName("18/1/1993")
  3899.  
  3900.                          would return "January"
  3901.  
  3902.         DateMonthStart
  3903.  
  3904.  
  3905.  
  3906.                Function  Get the month start date.
  3907.  
  3908.                  Syntax  DateMonthStart(date)
  3909.  
  3910.                 Returns  Date of the first day of the month of the date
  3911.                          argument.
  3912.  
  3913.                 Example  DateMonthStart("3/5/1990")
  3914.  
  3915.                          would return "1/5/1990".  Note that the value
  3916.                          returned is really a date, not a string.
  3917.  
  3918.  
  3919.  
  3920.         54                                           Nadir Reference Manual
  3921.  
  3922.  
  3923.  
  3924.  
  3925.         DateToday
  3926.  
  3927.  
  3928.  
  3929.                Function  Return today's date.
  3930.  
  3931.                  Syntax  DateToday()
  3932.  
  3933.                 Returns  Today's date.
  3934.  
  3935.         DateYear
  3936.  
  3937.  
  3938.  
  3939.                Function  Get year component of date
  3940.  
  3941.                  Syntax  DateYear(date)
  3942.  
  3943.                 Returns  The year number of the date argument.
  3944.  
  3945.                 Example  DateYear("03/05/1990")
  3946.  
  3947.                          would return 1990.
  3948.  
  3949.         Dump
  3950.  
  3951.  
  3952.  
  3953.                Function  Dump values to the Nadir output file.
  3954.  
  3955.                  Syntax  Dump(arg...)
  3956.  
  3957.                 Returns  Null Value
  3958.  
  3959.                 Remarks  This routine is used to dump fields to the output
  3960.                          file.  The format of the output is such that the
  3961.                          type of field can be determined.  This function
  3962.                          may be used  for dump and load type operations
  3963.                          with symbol tables.
  3964.  
  3965.                          Dump attempts to limit the width of the standard
  3966.                          output to 80 characters.  If strings are longer,
  3967.                          Dump will continue strings like continued strings
  3968.                          in the Nadir language.
  3969.  
  3970.                          Example
  3971.  
  3972.                          Dump("ab\ncd")           "ab\ncd"
  3973.  
  3974.                          Dump("very long string") "very lo\
  3975.                                                   ng string"
  3976.  
  3977.                          Dump(123)                123
  3978.  
  3979.                          Dump(123.45)             123.45
  3980.  
  3981.                          Dump("1/1/1992")         "01/01/1992"
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.         Chapter 6    System Intrinsic Functions                          55
  3988.  
  3989.  
  3990.  
  3991.  
  3992.                          Dump(Bunch(1,1.2,"abc")) Bunch(1, 1.2, "abc")
  3993.  
  3994.                          In the second example, the continuation is really
  3995.                          performed at the 80th character of a long string.
  3996.                          The example is given to show how a long string is
  3997.                          continued on the next line.
  3998.  
  3999.         Explode
  4000.  
  4001.  
  4002.  
  4003.                Function  Break a string into components
  4004.  
  4005.                  Syntax  Explode(str, delimiter, &var1, &var2, &var3 ...)
  4006.  
  4007.                 Returns  The number of components in str that are
  4008.                          separated by the delimiter character. This is the
  4009.                          same as the number of delimeters + 1.
  4010.  
  4011.                 Remarks  If a delimiter is not specified, "^" is assumed.
  4012.  
  4013.                          var1 will be set to the first component, var2 to
  4014.                          the second and so on.  If there are more
  4015.                          variables than components, remaining variables
  4016.                          are set to the null value.
  4017.  
  4018.                          This function may be used to break a variable
  4019.                          name into components.
  4020.  
  4021.                 Example  explode("fred^mary^joan", "^", &loc1, &loc2,
  4022.                          &loc3)
  4023.  
  4024.                          would set loc1 to "fred", loc2 to "mary", loc3 to
  4025.                          "joan" and return 3.
  4026.  
  4027.         Exit
  4028.  
  4029.  
  4030.  
  4031.                Function  Exit the Nadir program.
  4032.  
  4033.                  Syntax  Exit(msg, retCode)
  4034.  
  4035.                 Returns  Does not return.
  4036.  
  4037.                 Remarks  If the msg argument specified, it is displayed as
  4038.                          an abnormal termination message.
  4039.  
  4040.                          The Nadir program is exited.  The exit occurs
  4041.                          even if cycling is specified on the command line
  4042.                          when starting Nadir.
  4043.  
  4044.                          If retCode is specified, it will be the exit
  4045.                          status of the Nadir program.  If it is not
  4046.                          specified a value of zero will be returned.
  4047.  
  4048.  
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.         56                                           Nadir Reference Manual
  4055.  
  4056.  
  4057.  
  4058.  
  4059.         FieldType
  4060.  
  4061.  
  4062.  
  4063.                Function  Get field type.
  4064.  
  4065.                  Syntax  FieldType(arg)
  4066.  
  4067.                 Returns  The field type of the argument.  Will be one of
  4068.                          the following
  4069.  
  4070.                          "STRING"
  4071.                          "INT"          - integer field.
  4072.                          "FLOAT"
  4073.                          "DATE"
  4074.                          "BUNCH"
  4075.  
  4076.                 Remarks  The type returned is the actual type of the
  4077.                          field.  For example, if arg is a string that
  4078.                          contains "123", "STRING" will be returned.
  4079.  
  4080.         FileClose
  4081.  
  4082.  
  4083.  
  4084.                Function  Close file opened with FileOpen
  4085.  
  4086.                  Syntax  FileClose(handle)
  4087.  
  4088.                 Returns  Null value.
  4089.  
  4090.                 Remarks  The file, specified by the handle argument is
  4091.                          closed.  The handle is the value returned from
  4092.                          the FileOpen function.
  4093.  
  4094.         FileColumn
  4095.  
  4096.  
  4097.  
  4098.                Function  Return current column in a file.
  4099.  
  4100.                  Syntax  FileColumn(handle)
  4101.  
  4102.                 Returns  The column number, 0 for first column.
  4103.  
  4104.                 Remarks  The column number is returned for the file opened
  4105.                          with the handle specified by the handle argument.
  4106.  
  4107.                          The current column is maintained for a file
  4108.                          opened for output.  It is reset to zero when a
  4109.                          newline is printed to the file.  Any other
  4110.                          character printed to the file increments the
  4111.                          column number by 1.
  4112.  
  4113.         FileDump
  4114.  
  4115.  
  4116.  
  4117.                Function  Dump fields to a file.
  4118.  
  4119.  
  4120.  
  4121.         Chapter 6    System Intrinsic Functions                          57
  4122.  
  4123.  
  4124.  
  4125.  
  4126.                  Syntax  FileDump(handle, arg ...)
  4127.  
  4128.                 Returns  Null value
  4129.  
  4130.                 Remarks  Same as Dump function, except output is to the
  4131.                          file specified by the handle argument.
  4132.  
  4133.         FileIndentSet
  4134.  
  4135.  
  4136.  
  4137.                Function  Set the indent number for a file.
  4138.  
  4139.                  Syntax  FileIndentSet(handle, indent)
  4140.  
  4141.                 Returns  The original value of the indent number.
  4142.  
  4143.                 Remarks  The indent number is set for the file opened with
  4144.                          the handle specified by the handle argument.
  4145.  
  4146.                          The indent argument specifies the value that the
  4147.                          indent column number is to be set to.
  4148.  
  4149.                          When Nadir is outputting to a file, if the
  4150.                          character to output is not a newline, and the
  4151.                          current column number is zero, Nadir will output
  4152.                          the indent number of spaces before the character
  4153.                          is output.
  4154.  
  4155.         FileLineGet
  4156.  
  4157.  
  4158.  
  4159.                Function  Get next line from file opened with FileOpen
  4160.  
  4161.                  Syntax  FileLineGet(handle, &var, lnlFlag)
  4162.  
  4163.                 Returns  Returns error status, 0 (zero) if line was read
  4164.                          successfully, non zero for end of file.
  4165.  
  4166.                 Remarks  The line is read from the file opened with the
  4167.                          handle specified by the handle argument into the
  4168.                          variable, var.
  4169.  
  4170.                          If lnlFlag, leave newline flag, is false, the
  4171.                          newline character that separates lines is
  4172.                          removed.  This is the default action.  If lnlFlag
  4173.                          is true, any newline character at the end of the
  4174.                          buffer is not removed.
  4175.  
  4176.                          Note that the variable has to be passed by
  4177.                          reference, if its value is to be set.
  4178.  
  4179.         FileOpen
  4180.  
  4181.  
  4182.  
  4183.                Function  Open a text file for reading or writing.
  4184.  
  4185.  
  4186.  
  4187.  
  4188.         58                                           Nadir Reference Manual
  4189.  
  4190.  
  4191.  
  4192.  
  4193.                  Syntax  FileOpen(fileName, mode)
  4194.  
  4195.                 Returns  The file handle to be used in subsequent
  4196.                          FileRead, FileLineGet, FilePrint, FileDump and
  4197.                          FileClose function calls.  If the file cannot be
  4198.                          opened, zero is returned.
  4199.  
  4200.                 Remarks  fileName specifies the name of the file to be
  4201.                          opened.  If no path information is present in
  4202.                          fileName, the file is opened in the directory
  4203.                          specified by the -D command line switch, or the
  4204.                          current directory if -D was not used.
  4205.  
  4206.                          The mode string may contain a word.  The first
  4207.                          character of the word can specify one  the
  4208.                          following types.  Case is not significant.
  4209.  
  4210.                          "R"ead    Existing file is opened for
  4211.                                    reading.
  4212.  
  4213.                          "W"rite   File is created and opened for
  4214.                                    writing.
  4215.  
  4216.                          "A"ppend  Existing file is opened for
  4217.                                    append.  Information is written to
  4218.                                    the end of the file.  If the file
  4219.                                    does not exist, file will be
  4220.                                    created.
  4221.  
  4222.                 Example  Following example demonstrates the FileOpen,
  4223.                          FileLineGet, FilePrint and FileClose functions.
  4224.                          When it is processed, c:\autoexec.bat is printed
  4225.                          to the Nadir output file, and is also printed to
  4226.                          a file \tmp\junk.
  4227.  
  4228.                          Define TestFile()
  4229.                          {
  4230.                               if (!(infile = FileOpen(`c:\autoexec.bat`,
  4231.                          "read")))
  4232.                                    Signal("Could not open input file");
  4233.                               if (!(outfile = FileOpen(`\tmp\junk`,
  4234.                          "write")))
  4235.                                    Signal("Could not open output file");
  4236.                               while (!FileLineGet(infile, &buff)) {
  4237.                                    Print(buff, "\n");
  4238.                                    FilePrint(outfile, buff, "\n");
  4239.                               }
  4240.                               FileClose(infile);
  4241.                               FileClose(outfile);
  4242.                          }
  4243.                          TestFile
  4244.  
  4245.         FilePrint
  4246.  
  4247.  
  4248.  
  4249.                Function  Print fields to a file.
  4250.  
  4251.                  Syntax  FilePrint(handle, arg ...)
  4252.  
  4253.  
  4254.  
  4255.         Chapter 6    System Intrinsic Functions                          59
  4256.  
  4257.  
  4258.  
  4259.  
  4260.                 Returns  Null value
  4261.  
  4262.                 Remarks  Same as Print function, except output is to the
  4263.                          file specified by the handle argument.
  4264.  
  4265.         FileRemove
  4266.  
  4267.  
  4268.  
  4269.                Function  Remove a file.
  4270.  
  4271.                  Syntax  FileRemove(fileName)
  4272.  
  4273.                 Returns  Returns error status, 0 (zero) if file was
  4274.                          deleted successfully, non zero if it was not
  4275.                          deleted.
  4276.  
  4277.                 Remarks  fileName specifies the name of the file to be
  4278.                          deleted.
  4279.  
  4280.         FloatToInt
  4281.  
  4282.  
  4283.  
  4284.                Function  Convert a float to an integer.
  4285.  
  4286.                  Syntax  FloatToInt(arg)
  4287.  
  4288.                 Returns  The integer value of arg.  If arg is not a float,
  4289.                          or cannot be converted to a float, zero is
  4290.                          returned.
  4291.  
  4292.         Level
  4293.  
  4294.  
  4295.  
  4296.                Function  Get procedure level.
  4297.  
  4298.                  Syntax  Level()
  4299.  
  4300.                 Returns  An integer, the level within the execution
  4301.                          hierarchy.  The outermost level is level 0.
  4302.  
  4303.  
  4304.  
  4305.  
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.  
  4314.  
  4315.  
  4316.  
  4317.  
  4318.  
  4319.  
  4320.  
  4321.  
  4322.         60                                           Nadir Reference Manual
  4323.  
  4324.  
  4325.  
  4326.  
  4327.                 Example  Define Level00()
  4328.                          {
  4329.                               Print("Entering Level00, Level is ",
  4330.                          Level(), "\n");
  4331.                               Level01();
  4332.                               Print("Leaving level00, Level is ", Level(),
  4333.                          "\n");
  4334.                          }
  4335.                          Define Level01()
  4336.                          {
  4337.                               Print("  In Level01, Level is ", Level(),
  4338.                          "\n");
  4339.                          }
  4340.                          Level00
  4341.  
  4342.                          when processed, will output
  4343.  
  4344.                          Entering Level00, Level is 0
  4345.                            In Level01, Level is 1
  4346.                          Leaving level00, Level is 0
  4347.  
  4348.         LineCurr
  4349.  
  4350.  
  4351.  
  4352.                Function  Get contents of current line in input file
  4353.  
  4354.                  Syntax  LineCurr(&var, lnlFlag)
  4355.  
  4356.                 Returns  Returns null value.
  4357.  
  4358.                 Remarks  The current line being processed in the Nadir
  4359.                          input file, is copied into the specified
  4360.                          variable,var.
  4361.  
  4362.                          If lnlFlag, leave newline flag, is false, the
  4363.                          newline character that separates lines is
  4364.                          removed.  This is the default action.  If lnlFlag
  4365.                          is true, any newline character at the end of the
  4366.                          buffer is not removed.
  4367.  
  4368.                          Note that the variable has to be passed by
  4369.                          reference, if its value is to be set.
  4370.  
  4371.                          See example in LineGet to see how a macro can be
  4372.                          used to process lines from the input file.
  4373.  
  4374.         LineGet
  4375.  
  4376.  
  4377.  
  4378.                Function  Get next line from the input file.
  4379.  
  4380.                  Syntax  LineGet(&var, lnlFlag)
  4381.  
  4382.                 Returns  Returns error status, 0 (zero) if line was read
  4383.                          successfully, non zero for end of file.
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.         Chapter 6    System Intrinsic Functions                          61
  4390.  
  4391.  
  4392.  
  4393.  
  4394.                 Remarks  The next line is read from the Nadir input file,
  4395.                          and the resulting line is copied into the
  4396.                          specified variable, var.
  4397.  
  4398.                          If lnlFlag, leave newline flag, is false, the
  4399.                          newline character that separates lines is
  4400.                          removed.  This is the default action.  If lnlFlag
  4401.                          is true, any newline character at the end of the
  4402.                          buffer is not removed.
  4403.  
  4404.                          Note that the variable has to be passed by
  4405.                          reference, if its value is to be set.
  4406.  
  4407.                          The line is initially read into the buffer used
  4408.                          by lexical analysis when processing the Nadir
  4409.                          input file.  Using this macro, in conjunction
  4410.                          with LineCurr, allows the user to process the
  4411.                          input file by lines in a user written macro.
  4412.  
  4413.                 Example  When the following input is processed,
  4414.  
  4415.                          Define Testit()
  4416.                          /*
  4417.                              Testit reads lines after it is invoked,
  4418.                              and outputs them prefixed with 4 percent
  4419.                          signs.
  4420.                              This finishes with a line containing
  4421.                          EndTestit
  4422.                          */
  4423.                          {
  4424.                            LineCurr(&buff);
  4425.                            do {
  4426.                              if (buff == "EndTestit") {
  4427.                                LineGet();
  4428.                                TokenNext();   /* move lexical analysis off
  4429.                          token
  4430.                                                  after Testit word, and
  4431.                          onto token
  4432.                                                  after EndTestit line */
  4433.                                return;
  4434.                              }
  4435.                              Print("%%%%",buff,"\n");
  4436.                            } while (!LineGet(&buff));
  4437.                          }
  4438.                          aaaaaaaaaa
  4439.                          Testit
  4440.                          bbbbbbbbbb
  4441.                          cccccccccc
  4442.                          EndTestit
  4443.                          dddddddddd
  4444.  
  4445.                          The following output is produced.
  4446.  
  4447.                          aaaaaaaaaa
  4448.                          %%%%bbbbbbbbbb
  4449.                          %%%%cccccccccc
  4450.                          dddddddddd
  4451.  
  4452.  
  4453.  
  4454.  
  4455.  
  4456.         62                                           Nadir Reference Manual
  4457.  
  4458.  
  4459.  
  4460.  
  4461.         LineNum
  4462.  
  4463.  
  4464.  
  4465.                Function  Get line number in the input file.
  4466.  
  4467.                  Syntax  LineNum()
  4468.  
  4469.                 Returns  Returns the line number of the current line being
  4470.                          processed in the input file.  The first line in
  4471.                          the file is line number 1.
  4472.  
  4473.         OutputColumn
  4474.  
  4475.  
  4476.  
  4477.                Function  Return current column in the output file.
  4478.  
  4479.                  Syntax  OutputColumn()
  4480.  
  4481.                 Returns  The column number, 0 for first column.
  4482.  
  4483.                 Remarks  The current column is maintained for the output
  4484.                          file.  It is reset to zero when a newline is
  4485.                          printed to the output file.  Any other character
  4486.                          printed to the output file increments the column
  4487.                          number by 1.
  4488.  
  4489.         OutputIndentSet
  4490.  
  4491.  
  4492.  
  4493.                Function  Set the indent number for the output file.
  4494.  
  4495.                  Syntax  OutputIndentSet(indent)
  4496.  
  4497.                 Returns  The original value of the indent number.
  4498.  
  4499.                 Remarks  The indent argument specifies the value that the
  4500.                          indent column number is to be set to.
  4501.  
  4502.                          When Nadir is outputting to the output file, if
  4503.                          the character to output is not a newline, and the
  4504.                          current column number is zero, Nadir will output
  4505.                          the indent number of spaces before the character
  4506.                          is output.
  4507.  
  4508.         PreProcessSet
  4509.  
  4510.  
  4511.  
  4512.                Function  Set pre-process flags.
  4513.  
  4514.                  Symtax  PreProcessSet(string)
  4515.  
  4516.                 Returns  Returns a string, the original value of the pre-
  4517.                          process mode flags.
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.         Chapter 6    System Intrinsic Functions                          63
  4524.  
  4525.  
  4526.  
  4527.  
  4528.                 Remarks  The string argument specifies the required value
  4529.                          for the pre-process flags.  It may conain the
  4530.                          following characters :-
  4531.  
  4532.                          Char      Meaning
  4533.  
  4534.                          d         Define keyword in input
  4535.                                    file is ignored
  4536.                          e         Eval is ignored
  4537.                          i         If, Elseif, Else and
  4538.                                    Endif are ignored.
  4539.  
  4540.                          By ignoring all keywords, only user written
  4541.                          macros are expanded.  Using this feature, a user
  4542.                          can pre process Nadir code.
  4543.  
  4544.                          Pre-process flags may be initially set by using
  4545.                          the -n command line switch.
  4546.  
  4547.                 Example  The following example defines a couple of useful
  4548.                          macros that may be used to change the mode.
  4549.  
  4550.                          Define PreProcessOn(flags)    /* turns on pre
  4551.                          processing */
  4552.                          {
  4553.                              PreProcessSet(flags ? flags : "dei");
  4554.                          }
  4555.                          Define PreProcessOff         /* turns off pre
  4556.                          processing */
  4557.                          {
  4558.                              PreProcessSet("");
  4559.                          }
  4560.                          Define MyMacro(a,b)          /* pre processing
  4561.                          off
  4562.                                                          by default */
  4563.                          {
  4564.                              return a + b;
  4565.                          }
  4566.                          PreProcessOn
  4567.                          Define Testit {
  4568.                              a = MyMacro(4, 3);
  4569.                          }
  4570.  
  4571.                          When the above is processed (without the -n
  4572.                          switch), the following output is produced.
  4573.  
  4574.                          Define Testit {
  4575.                              a = 7;
  4576.                          }
  4577.  
  4578.         Print
  4579.  
  4580.  
  4581.  
  4582.                Function  Print to the Nadir output file.
  4583.  
  4584.                  Syntax  Print(arg ...)
  4585.  
  4586.                 Returns  Null Value
  4587.  
  4588.  
  4589.  
  4590.         64                                           Nadir Reference Manual
  4591.  
  4592.  
  4593.  
  4594.  
  4595.                 Remarks  Print outputs all the given arguments to the
  4596.                          Nadir output file.
  4597.  
  4598.                          If arg is a bunch, the elements of the bunch are
  4599.                          printed, separated by commas, and enclosed in
  4600.                          parentheses, "(" and ")".
  4601.  
  4602.                 Example  Code                          Result
  4603.  
  4604.                          Print(1, 2, "abc")            12abc
  4605.  
  4606.                          Print("abc\ndef")             abc
  4607.                                                        def
  4608.  
  4609.                          myBunch = Bunch(1,2,3,"abc"); (1, 2, 3,
  4610.                          Print(myBunch)                abc)
  4611.  
  4612.         Process
  4613.  
  4614.  
  4615.  
  4616.                Function  Performs Nadir input to output processing on
  4617.                          strings.
  4618.  
  4619.                  Syntax  Process(input, &output)
  4620.  
  4621.                 Returns  Returns a string.  If no error, returns a null
  4622.                          string.  If an error occurs either in the syntax,
  4623.                          or execution of the arguments, the text of the
  4624.                          error is returned.
  4625.  
  4626.                 Remarks  The input is converted to a string, if necessary.
  4627.                          This string is then processed as if it had
  4628.                          occurred in Nadir's input file.  The ouput of the
  4629.                          processing is returned in the output argument.
  4630.                          This variable has to be passed by reference.
  4631.  
  4632.                          If an error occurs in the execution, any resource
  4633.                          that was allocated may not be released.  For
  4634.                          simple expressions, no resources would probably
  4635.                          be involved, however if functions are called,
  4636.                          access counts will not be decremented, and any
  4637.                          handles, memory etc will not be released as
  4638.                          processing stops when the error occurs.  The
  4639.                          safest method is to call Signal with the error
  4640.                          message to restart the system.
  4641.  
  4642.                 Example  myString = `Eval(DateToday() - "15/10/1955")`;
  4643.                          Process(myString, &result);
  4644.  
  4645.                          This example, when written in a function,
  4646.                          compiles and runs the string in myString as if it
  4647.                          had occurred in the input file.  The age in days,
  4648.                          of a person born on 15 October 1955 is written to
  4649.                          the variable called result.
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.         Chapter 6    System Intrinsic Functions                          65
  4658.  
  4659.  
  4660.  
  4661.  
  4662.         Signal
  4663.  
  4664.  
  4665.  
  4666.                Function  Display an error message, and restart depending
  4667.                          on startup parameter.
  4668.  
  4669.                  Syntax  Signal(arg)
  4670.  
  4671.                 Returns  Does not return.
  4672.  
  4673.                 Remarks  The argument, arg, is converted to a string and
  4674.                          is displayed as a condition message.  If cycling
  4675.                          was specified on the command line, the Nadir
  4676.                          program is restarted.  If cycling was not
  4677.                          specified, the Nadir program is terminated.
  4678.  
  4679.         Spawn
  4680.  
  4681.  
  4682.  
  4683.                Function  Execute another program.
  4684.  
  4685.                  Syntax  Spawn(string, silent)
  4686.  
  4687.                 Returns  An integer, the called program's exit status or -
  4688.                          1.  -1 is returned if the program could not be
  4689.                          run, either the argument list to the program was
  4690.                          too long, the path or file could not be found, or
  4691.                          there was not enough memory.
  4692.  
  4693.                 Remarks  If used under Windows, this function is the same
  4694.                          as System.
  4695.  
  4696.                          Under DOS, it has different behaviour to System.
  4697.  
  4698.                          The string is parsed as if it was a command.  The
  4699.                          first word specifies the program to run.  The
  4700.                          other words are built into list of arguments, and
  4701.                          the runtime library function spawnvp is called to
  4702.                          execute the program.
  4703.  
  4704.                          The purpose of this function is to allow programs
  4705.                          to be called and their exit status to be
  4706.                          examined.
  4707.  
  4708.                          The silent argument is a boolean value.  If true,
  4709.                          it is assumed that the spawned program will not
  4710.                          perform any output to the screen.  The screen
  4711.                          contents are not saved before spawning or
  4712.                          restored after the program has finished.
  4713.  
  4714.         SpawnRestart
  4715.  
  4716.  
  4717.  
  4718.                Function  Execute another program and then restart Nadir.
  4719.  
  4720.                  Syntax  SpawnRestart(string, silent)
  4721.  
  4722.  
  4723.  
  4724.         66                                           Nadir Reference Manual
  4725.  
  4726.  
  4727.  
  4728.  
  4729.                 Returns  Resturn is never made, since system is restarted.
  4730.  
  4731.                 Remarks  This function is available under DOS only.
  4732.  
  4733.                          It is the same as the Spawn function, except all
  4734.                          data files are closed before the program is
  4735.                          invoked.  On return, Nadir is restarted, if the
  4736.                          cycle on errors switch was specified on the
  4737.                          command line.
  4738.  
  4739.         StrCat
  4740.  
  4741.  
  4742.  
  4743.                Function  Concatenate strings.
  4744.  
  4745.                  Syntax  StrCat(arg ...)
  4746.  
  4747.                 Returns  The string formed by concatenating the arguments.
  4748.  
  4749.                 Remarks  Arguments are converted to strings.
  4750.  
  4751.                          This function was used before the concatenation
  4752.                          operator was developed.
  4753.  
  4754.                 Example  Print(StrCat("abc", 12, "def"));
  4755.  
  4756.                          will print
  4757.  
  4758.                          abc12def
  4759.  
  4760.         StrFromAscii
  4761.  
  4762.  
  4763.  
  4764.                Function  Convert an ascii value to a character string.
  4765.  
  4766.                  Syntax  StrFromAscii(arg)
  4767.  
  4768.                 Returns  A character string which contains the byte with
  4769.                          the ascii value of the integer argument.
  4770.  
  4771.                 Remarks  arg is converted to an integer.  If arg is not a
  4772.                          valid integer, the null value is returned. If arg
  4773.                          is greater than 255, the least significant byte
  4774.                          is placed in the result.
  4775.  
  4776.                 Example  StrFromAcsii(48) returns "0"
  4777.  
  4778.         StrFromLit
  4779.  
  4780.  
  4781.  
  4782.                Function  Convert a literal to a string.
  4783.  
  4784.                  Syntax  StrFromLit(string)
  4785.  
  4786.                 Returns  The string formed by converting the string
  4787.                          literal argument.
  4788.  
  4789.  
  4790.  
  4791.         Chapter 6    System Intrinsic Functions                          67
  4792.  
  4793.  
  4794.  
  4795.  
  4796.                 Remarks  This function performs the reverse of StrToLit.
  4797.                          i.e. If the characters backslash lowercase n are
  4798.                          in the argument, the returned string will contain
  4799.                          1 character, the newline character.
  4800.  
  4801.                          A sequence of backslash newline is dropped.  This
  4802.                          is how long strings are continued.
  4803.  
  4804.                          The valid sequences in the string literal are :-
  4805.  
  4806.                               \a      audible (bell) character.
  4807.                               \b      backspace.
  4808.                               \f      formfeed.
  4809.                               \n      newline.
  4810.                               \r      carriage return.
  4811.                               \t      tab.
  4812.                               \v      vertical tab.
  4813.                               \\      backslash.
  4814.                               \'      single quote.
  4815.                               \"      double quotes.
  4816.                               \x      2 digit hexadecimal constant
  4817.                                       follows
  4818.                               \nnn    3 digit octal constant.
  4819.  
  4820.                          Since the function does not error, there are
  4821.                          slight differences to the lexical analysis
  4822.                          performed on string literals in the Macro
  4823.                          Language.
  4824.  
  4825.                          If the string ends with a single backslash, a
  4826.                          backslash is output.
  4827.  
  4828.                          If there are not 2 valid hex characters after a
  4829.                          \x, the value found so far is output to the
  4830.                          result.  eg "\xaz" would produce the same result
  4831.                          as "\x0az", and "\xzz" would produce the same
  4832.                          output as "\x00zz".  Similarly, the conversion
  4833.                          routine continues if there are not 3 valid octal
  4834.                          characters for the octal constant.
  4835.  
  4836.         StrFromQuoted
  4837.  
  4838.  
  4839.  
  4840.                Function  Convert from a quoted string to a string.
  4841.  
  4842.                  Syntax  StrFromQuoted(string)
  4843.  
  4844.                 Returns  The string formed by converting the quoted string
  4845.                          argument.
  4846.  
  4847.                 Remarks  A quoted string begins and ends with a matching
  4848.                          single quotes, double quotes or accents.  If
  4849.                          string is not one of these, the return value will
  4850.                          be the same as string.
  4851.  
  4852.  
  4853.  
  4854.  
  4855.  
  4856.  
  4857.  
  4858.         68                                           Nadir Reference Manual
  4859.  
  4860.  
  4861.  
  4862.  
  4863.                          If string has matching single or double quotes,
  4864.                          these are dropped, and the remaining characters
  4865.                          are converted to a string using the same rules as
  4866.                          StrFromLit.
  4867.  
  4868.                          If string has matching accents, the accents are
  4869.                          dropped.
  4870.  
  4871.                          Remember that when processing input, arguments to
  4872.                          macros are either strings or quoted strings.
  4873.                          This function may be used to convert quoted
  4874.                          string arguments passed to a macros.
  4875.  
  4876.                Examples  Following results are the output from a
  4877.                          Print(StrFromQuoted(Arguments));
  4878.  
  4879.                          For the first example it would be
  4880.                          Print(StrFromQuoted("\"abc\""));  The double
  4881.                          quotes have to be escaped to get the double
  4882.                          quotes into the string.
  4883.  
  4884.                          Arguments      No of     Printed        No of
  4885.                          contain        chars     Result         chars
  4886.  
  4887.                          "abc"          5         abc            3
  4888.                          "abc\ndef"     10        abc            7
  4889.                                                   def
  4890.                          'abc\x20def'   12        abc def        7
  4891.                          `abc           9         abc            7
  4892.                          def`                     def
  4893.                          abc\ndef       8         abc\ndef       8
  4894.  
  4895.                          If the following input file is processed
  4896.  
  4897.                          Define PrintIt(arg)
  4898.                          {
  4899.                              Print(StrFromQuoted(arg));
  4900.                          }
  4901.                          PrintIt("abc\ndef")        Quoted String
  4902.                          PrintIt(abc\ndef)          Not a quoted string
  4903.  
  4904.                          The following output file would be produced
  4905.  
  4906.                          abc
  4907.                          def        Quoted String
  4908.                          abc\ndef          Not a quoted string
  4909.  
  4910.         StrLen
  4911.  
  4912.  
  4913.  
  4914.                Function  Obtain string length.
  4915.  
  4916.                  Syntax  StrLen(string)
  4917.  
  4918.                 Returns  The number of characters in the string argument.
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.         Chapter 6    System Intrinsic Functions                          69
  4926.  
  4927.  
  4928.  
  4929.  
  4930.         StrMatch
  4931.  
  4932.  
  4933.  
  4934.                Function  Test if string matches a regular expression type
  4935.                          pattern.
  4936.  
  4937.                  Syntax  StrMatch(pattern, string)
  4938.  
  4939.                 Returns  1 if string matches the pattern, 0 if it doesn't.
  4940.  
  4941.                 Remarks  The second argument is the string that is matched
  4942.                          against the pattern.
  4943.  
  4944.                          Characters that have special meaning in the
  4945.                          pattern are :-
  4946.  
  4947.                          ?       Match any character in this position.
  4948.                          *       Match zero or more characters.
  4949.                          !       If first character in pattern, negates
  4950.                                  match expression.
  4951.                                  Has no significance if not the first
  4952.                                  character in pattern or not the first
  4953.                                  character after [
  4954.                          \       Quotes following character so it is
  4955.                                  taken literally
  4956.                          |       Logical or between two or more
  4957.                                  patterns to use to match the string.
  4958.                                  eg  bob|mary would match either bob or
  4959.                                  mary
  4960.                          [..]    Defines a group of characters to match
  4961.                                  at the current position.
  4962.  
  4963.                          The following characters have special meaning
  4964.                          inside square brackets.
  4965.  
  4966.                          !       If first character negates character
  4967.                                  set.
  4968.                          -       Used to specify a range. eg. a-z
  4969.                                  specifies the chars from 'a' to 'z'
  4970.                                  inclusive.
  4971.                                  eg [!-a-z] means not minus sign and
  4972.                                  not characters a to z.
  4973.                          \       Quotes special characters.
  4974.  
  4975.                Examples  Pattern             String         Result
  4976.  
  4977.                          ab*cd               abcd           1
  4978.                          ab*cd               abxxxcdcd      1
  4979.                          ab?cd               abcd           0
  4980.                          ab?cd               abccd          1
  4981.                          !ab*cd              abcd           0
  4982.                          [0-9][0-9]\|[a-z]   34|p           1
  4983.         StrPos
  4984.  
  4985.  
  4986.  
  4987.                Function  Find position of a string in another string.
  4988.  
  4989.  
  4990.  
  4991.  
  4992.         70                                           Nadir Reference Manual
  4993.  
  4994.  
  4995.  
  4996.  
  4997.                  Syntax  StrPos(string, substring)
  4998.  
  4999.                 Returns  Returns the offset in string of the first
  5000.                          occurrence of substring.
  5001.  
  5002.                 Remarks  Offset 0 means the first character.  It the
  5003.                          substring is not found in string, -1 is returned.
  5004.  
  5005.         StrSubs
  5006.  
  5007.  
  5008.  
  5009.                Function  Extract a string from a string.
  5010.  
  5011.                  Syntax  StrSubs(string, offset, length)
  5012.  
  5013.                 Returns  Returns the substring which has length characters
  5014.                          at offset characters in string.
  5015.  
  5016.                 Remarks  The offset of the first character is 0.  If
  5017.                          offset is too large, the null value is returned.
  5018.                          If length is zero, or undefined, the rest of the
  5019.                          string after offset is returned.
  5020.  
  5021.         StrToAscii
  5022.  
  5023.  
  5024.  
  5025.                Function  Convert a character to an ascii value.
  5026.  
  5027.                  Syntax  StrToAscii(string)
  5028.  
  5029.                 Returns  The ascii value of the first byte of the string
  5030.                          argument.
  5031.  
  5032.                 Remarks  StrToAscii returns zero if string has zero length
  5033.  
  5034.                 Example  StrToAcsii("0aB") returns 48.
  5035.  
  5036.         StrToLit
  5037.  
  5038.  
  5039.  
  5040.                Function  Convert string to a literal
  5041.  
  5042.                  Syntax  StrToLit(string)
  5043.  
  5044.                 Returns  The string literal, formed by converting the
  5045.                          string argument.
  5046.  
  5047.                 Remarks  A string literal is the string of characters that
  5048.                          literally describe the contents of a string.  If
  5049.                          a string contains a newline character, the string
  5050.                          literal will contain 2 characters, a backslash
  5051.                          followed by a lowercase n.
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.         Chapter 6    System Intrinsic Functions                          71
  5060.  
  5061.  
  5062.  
  5063.  
  5064.                          For a list of the sequences that may be output
  5065.                          see StrFromLit.  If a character is not one of the
  5066.                          specified ones like newline, formfeed, vertical
  5067.                          tab etc, a hex constant sequence will be output.
  5068.  
  5069.                 Example  Statement                        would print
  5070.  
  5071.                          Print(StrToLit("Number\nis ",    Number\nis 42.02
  5072.                          42.02));
  5073.                          Print("Number\nis ", 42.02);     Number
  5074.                                                           is 42.02
  5075.  
  5076.         StrToLower
  5077.  
  5078.  
  5079.  
  5080.                Function  Convert characters to lowercase.
  5081.  
  5082.                  Syntax  StrToLower(string)
  5083.  
  5084.                 Returns  The string converted to lowercase.
  5085.  
  5086.                 Remarks  Any uppercase character is converted to
  5087.                          lowercase, any other characters are copied to the
  5088.                          return value unchanged.
  5089.  
  5090.         StrToUpper
  5091.  
  5092.  
  5093.  
  5094.                Function  Convert characters to uppercase.
  5095.  
  5096.                  Syntax  StrToUpper(string)
  5097.  
  5098.                 Returns  The string converted to uppercase
  5099.  
  5100.                 Remarks  Any lowercase character is converted to
  5101.                          uppercase, any other characters are copied to the
  5102.                          return value unchanged.
  5103.  
  5104.         SymClose
  5105.  
  5106.  
  5107.  
  5108.                Function  Close a symbol table.
  5109.  
  5110.                  Syntax  SymClose(symtabName)
  5111.  
  5112.                 Returns  Null value.
  5113.  
  5114.                 Remarks  The symbol table, specified by symtabName is
  5115.                          closed.  Access is not possible until SymOpen is
  5116.                          performed for the symbol table.
  5117.  
  5118.         SymCreate
  5119.  
  5120.  
  5121.  
  5122.                Function  Create a symbol table file, and open for access.
  5123.  
  5124.  
  5125.  
  5126.         72                                           Nadir Reference Manual
  5127.  
  5128.  
  5129.  
  5130.  
  5131.                  Syntax  SymCreate(symtabName, fileName, type, blkSize,
  5132.                          buffCnt)
  5133.  
  5134.                 Returns  Returns an error status.  0 for success, 1 for
  5135.                          file already exists.
  5136.  
  5137.                 Remarks  The function is used to create a symbol table
  5138.                          file.  After SymCreate, the symbol table is open
  5139.                          for use. ie It is not necessary to perform a
  5140.                          SymOpen.  For an explanation of the arguments,
  5141.                          see SymOpen.
  5142.  
  5143.         SymLock
  5144.  
  5145.  
  5146.  
  5147.                Function  Lock symbol tables to control access.
  5148.  
  5149.                  Syntax  SymLock(symtabName, updateFlag ...)
  5150.  
  5151.                 Returns  Null Value.  If return is made, lock requests
  5152.                          were granted.
  5153.  
  5154.                 Remarks  Aruments are pairs of symtabName, eg "univ", and
  5155.                          an updateFlag.  If updateFlag is true, the user
  5156.                          acquires an update lock, otherwise a read lock is
  5157.                          acquired.
  5158.  
  5159.                          Locks are required if a symbol table is not
  5160.                          temporary and not exclusively opened.
  5161.  
  5162.                          When an Update lock is acquired, no other user on
  5163.                          the system will be able to update the symbol
  5164.                          table until the lock is freed. Locks are freed
  5165.                          when SymLock is called again, or if
  5166.                          ScreenDialogues are used, an SdEdit function call
  5167.                          is performed.
  5168.  
  5169.                          SymLock unlocks any locks before performing the
  5170.                          locks.  The function locks the symbol tables in
  5171.                          the order they are specified in the argument
  5172.                          list. The order in the argument list should be
  5173.                          kept consistent in an application to avoid
  5174.                          deadlocks.
  5175.  
  5176.                          Read locks, when updateFlag is not set, are used
  5177.                          for reporting purposes.  i.e. another user may
  5178.                          get an update lock while you are using the file
  5179.                          in this mode.
  5180.  
  5181.                          If SymLock is not used, any access to a symbol
  5182.                          table file that has not been locked, is locked in
  5183.                          Update mode automatically. If the automatic
  5184.                          method is used, the order of locking depends on
  5185.                          the sequence in which the symbols are updated.
  5186.                          When this happens, deadlocks may occur.
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.         Chapter 6    System Intrinsic Functions                          73
  5194.  
  5195.  
  5196.  
  5197.  
  5198.                          If it is not possible to lock one of the symbol
  5199.                          tables, any locks that have already been
  5200.                          completed are unlocked, and control is passed to
  5201.                          a user written function called SymLockQuery. This
  5202.                          routine takes one argument, the filename and
  5203.                          should return 0 to retry the lock(s). Any other
  5204.                          response will cause a Signal to be performed.
  5205.  
  5206.         SymOpen
  5207.  
  5208.  
  5209.  
  5210.                Function  Open a symbol table file for access.
  5211.  
  5212.                  Syntax  SymOpen(symtabName, fileName, type, blkSize,
  5213.                          buffCnt)
  5214.  
  5215.                 Returns   Returns an error status.  0 for success, 1 for
  5216.                          file not found.
  5217.  
  5218.                 Remarks  symtabName is the name of the symbol table that
  5219.                          is being opened.  Examples are "univ", "glob",
  5220.                          "mdat", "parm", "data", "temp".  These are fixed
  5221.                          names that have specific meanings to Nadir.  A
  5222.                          number of user defined names may also be
  5223.                          specified.  The length is limited to 16
  5224.                          characters.  When symbols are referenced, this
  5225.                          name is the first component of the symbol name.
  5226.                          eg "univ^var^name".
  5227.  
  5228.                          fileName specifies the disk file name of the
  5229.                          symbol table.  If a directory name is not
  5230.                          included in the name, the -D parameter specified
  5231.                          on the command line is used.  If -D was not
  5232.                          specified, the current or working directory is
  5233.                          chosen.   If fileName is not specified, the
  5234.                          system default name, or the last name used for
  5235.                          the symbol table will be used.  The system
  5236.                          default is symtabName with the .DAT extension.
  5237.  
  5238.                          The fileName argument is ignored for temporary
  5239.                          files.  A temporary filename is generated.  The
  5240.                          file is created in the directory specified by the
  5241.                          -T command line parameter.  If -T was not
  5242.                          specified, a temporary file will be created in
  5243.                          the current or working directory.
  5244.  
  5245.                          If the symbol table is already open, SymOpen will
  5246.                          perform a SymClose.
  5247.  
  5248.                          The type string contains words separated by any
  5249.                          number of non-alpha chars and specifies the type
  5250.                          of symbol table that is to be opened.  The first
  5251.                          character of the word specifies the following
  5252.                          types.  Case is not significant.
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.         74                                           Nadir Reference Manual
  5261.  
  5262.  
  5263.  
  5264.  
  5265.                          "T"empora File is temporary and deleted when
  5266.                          ry        closed. If a file is temporary,
  5267.                                    exclusive use is assumed.  SymOpen
  5268.                                    and SymCreate is the same for
  5269.                                    temporary files.
  5270.  
  5271.                          "E"xclusi When opened has exclusive use.
  5272.                          ve        May not be shared with other
  5273.                                    users.
  5274.  
  5275.                                    If type is not specified, the
  5276.                                    default type is a permanent,
  5277.                                    shared file.
  5278.  
  5279.                          blkSize defines the size of each block or node in
  5280.                          the symbol table file.  If not specified, the
  5281.                          default size is 512 bytes.
  5282.  
  5283.                          blkSize will affect performance and the maximum
  5284.                          size of a symbol value.  If blkSize is too large,
  5285.                          too much memory will be used for buffers, and too
  5286.                          much time will be spent searching the node.  If
  5287.                          blkSize is too small, the symbol table will have
  5288.                          too many levels.  The size of a symbol name plus
  5289.                          its value needs to be less than half the blkSize
  5290.                          minus a bit for overheads.  blkSize can be
  5291.                          changed for an existing symbol table by using the
  5292.                          pack or copy function in the Symbol Table
  5293.                          Utility, stu.
  5294.  
  5295.                          buffCnt specifies the number of buffers that are
  5296.                          used when managing the symbol table.  If not
  5297.                          specified, a default number of 4 is chosen.  If a
  5298.                          number less than 2 is specified, 2 will be
  5299.                          chosen.
  5300.  
  5301.         SymRemove
  5302.  
  5303.  
  5304.  
  5305.                Function  Remove a symbol table file from disk.
  5306.  
  5307.                  Syntax  SymRemove(symtabName, fileName)
  5308.  
  5309.                 Returns  Returns an error status.  0 for success, non zero
  5310.                          if an error occurs.  Either the file did not
  5311.                          exist, or permission to delete was denied.
  5312.  
  5313.                 Remarks  If the symbol table, specified by symtabName is
  5314.                          opened, SymRemove will close it before performing
  5315.                          the delete.  If fileName is not specified, the
  5316.                          conventions described in SymOpen are followed.
  5317.                          symtabName is used to specify an internal slot to
  5318.                          use for the operation, fileName defines the disk
  5319.                          file that is removed.
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.         Chapter 6    System Intrinsic Functions                          75
  5328.  
  5329.  
  5330.  
  5331.  
  5332.         System
  5333.  
  5334.  
  5335.  
  5336.                Function  Perform a system call.
  5337.  
  5338.                  Syntax  System(string, silent)
  5339.  
  5340.                 Returns  For DOS, return value is zero if call is
  5341.                          successful, otherwise non zero.
  5342.  
  5343.                          For Windows, return value is zero if call was
  5344.                          successful, else the returned value is one more
  5345.                          than that returned by the Windows API WinExec
  5346.                          function.  i.e. Return value is 1 for Out of
  5347.                          memory.
  5348.  
  5349.                 Remarks  If string is not given, the DOS command.com file
  5350.                          is executed.  Under DOS, be sure that the Nadir
  5351.                          input file is not a disk file.  Either use the -i
  5352.                          switch on the command line when starting Nadir to
  5353.                          specify a file, or use System("command<con").
  5354.                          Also if the output is a file, use
  5355.                          System("command>con").
  5356.  
  5357.                          If string is present, it is passed as a command
  5358.                          to the command processor.
  5359.  
  5360.                          Under Windows, the WinExec API function is used.
  5361.                          This may be used to start other windows
  5362.                          applications, including another copy of Nadir.
  5363.  
  5364.                          The silent argument is a boolean value, and is
  5365.                          not used by the Windows version.  If true, any
  5366.                          output from the command is discarded.  The screen
  5367.                          contents are not saved before executing the
  5368.                          command or restored after the command has
  5369.                          finished.
  5370.  
  5371.         SystemRestart
  5372.  
  5373.  
  5374.  
  5375.                Function  Perform system call and restart Nadir.
  5376.  
  5377.                  Syntax  SystemRestart(string, silent)
  5378.  
  5379.                 Returns  Return is never made, since the system is
  5380.                          restarted.
  5381.  
  5382.                 Remarks  This function is available under DOS only.
  5383.  
  5384.                          It is the same as the System function, except all
  5385.                          data files are closed before the command
  5386.                          processor is invoked.  On return, Nadir is
  5387.                          restarted, if the cycle on errors switch was
  5388.                          specified on the command line.
  5389.  
  5390.  
  5391.  
  5392.  
  5393.  
  5394.         76                                           Nadir Reference Manual
  5395.  
  5396.  
  5397.  
  5398.  
  5399.                          SystemRestart may be used to allow batch files or
  5400.                          other programs access to files that the Nadir has
  5401.                          open.  These functions would include backup,
  5402.                          restore and file maintenance.
  5403.  
  5404.         SysType
  5405.  
  5406.  
  5407.  
  5408.                Function  Get System Type
  5409.  
  5410.                  Syntax  SysType()
  5411.  
  5412.                 Returns  The a string that contains the system type for
  5413.                          the Nadir program that is running.  Will be one
  5414.                          of :-
  5415.  
  5416.                          "DOS"     running DOS version, n.exe.
  5417.  
  5418.                          "WIN"     running Windows version, nw.exe and
  5419.                                    nsys.dll.
  5420.  
  5421.         TaskNum
  5422.  
  5423.  
  5424.  
  5425.                Function  Obtain unique task number.
  5426.  
  5427.                  Syntax  TaskNum()
  5428.  
  5429.                 Returns  The current task's task number.
  5430.  
  5431.                 Remarks  On the DOS version, this function always returns
  5432.                          0.
  5433.  
  5434.                          Using the Windows version, a number of tasks may
  5435.                          be started simultaneously.  Task numbers will
  5436.                          range from 0 to the maximum number of tasks that
  5437.                          may be started minus one.
  5438.  
  5439.         TimeNow
  5440.  
  5441.  
  5442.  
  5443.                Function  Get current time
  5444.  
  5445.                  Syntax  TimeNow()
  5446.  
  5447.                 Returns  A string containing the current time in format
  5448.                          "hh:mm:ss".
  5449.  
  5450.         TokenNext
  5451.  
  5452.  
  5453.  
  5454.                Function  Advance to the next token.
  5455.  
  5456.                  Syntax  TokenNext(comment)
  5457.  
  5458.  
  5459.  
  5460.  
  5461.         Chapter 6    System Intrinsic Functions                          77
  5462.  
  5463.  
  5464.  
  5465.  
  5466.                 Returns  The error message.  If no error occurred, the
  5467.                          null value is returned.
  5468.  
  5469.                 Remarks  Use this function to advance from one token to
  5470.                          the next.  See the remarks in TokenScanCreate for
  5471.                          the effect of TokenNext when TokenScanCreate has
  5472.                          not been performed.
  5473.  
  5474.                          If the comment argument is true, any comments
  5475.                          will be skipped over.  If comment is not
  5476.                          specified or is false, all the tokens in a
  5477.                          comment will be returned.  Comments are either
  5478.                          any text between /* and */, or between // and a
  5479.                          newline character.  If tokens in comments are
  5480.                          returned, they have to contain valid tokens, for
  5481.                          example quoted strings have to be correctly
  5482.                          terminated.
  5483.  
  5484.                          Note that an empty string contains one token, the
  5485.                          end of text token.
  5486.  
  5487.         TokenScanCreate
  5488.  
  5489.  
  5490.  
  5491.                Function  Create or initialize a token scan of a string.
  5492.  
  5493.                  Syntax  TokenScanCreate(string)
  5494.  
  5495.                 Returns  Null value.
  5496.  
  5497.                 Remarks  This function creates data structures and copies
  5498.                          the string argument.  The TokenNext function has
  5499.                          to be called to advance to the first token.
  5500.                          TokenType, TokenValue, TokenTerm may be used to
  5501.                          examine the current token.
  5502.  
  5503.                          If  TokenNext, TokenType, TokenValue, TokenTerm
  5504.                          are called without TokenScanCreate, the tokens in
  5505.                          the Nadir input are examined.  Nadir input is the
  5506.                          string after the -p command line switch, or if
  5507.                          that is not specified, the Nadir input file.
  5508.  
  5509.                          If  TokenScanCreate has been used,
  5510.                          TokenScanDestory should be used to free the data
  5511.                          structures that have been created.
  5512.  
  5513.                          A token scan may be performed within another
  5514.                          token scan.
  5515.  
  5516.  
  5517.  
  5518.  
  5519.  
  5520.  
  5521.  
  5522.  
  5523.  
  5524.  
  5525.  
  5526.  
  5527.  
  5528.         78                                           Nadir Reference Manual
  5529.  
  5530.  
  5531.  
  5532.  
  5533.                 Example  The following example shows how the Token
  5534.                          functions may be used to lexically analyse a
  5535.                          string.  It is intended to be the input to Nadir.
  5536.                          The second invokation of TestToken will produce
  5537.                          an error.
  5538.  
  5539.                          Define TestToken(str)
  5540.                          {
  5541.                              str = StrFromQuoted(str);
  5542.                              TokenScanCreate(str);
  5543.                              do {
  5544.                                  if (err = TokenNext()) {
  5545.                                      Print("error :- ", err);
  5546.                                      break;
  5547.                                  }
  5548.                                  Print(`term = "`,
  5549.                          StrToLit(TokenTerm()),`" `,
  5550.                                        `token = "`,
  5551.                          StrToLit(TokenValue()),`" `,
  5552.                                        `type = `, TokenType(), "\n");
  5553.                              } while (TokenType() != "EOT");
  5554.                              TokenScanDestroy();
  5555.                          }
  5556.                          TestToken(" aa\t 123 123.4  \"abcd\"
  5557.                          \"20/9/1953\" while")
  5558.                          TestToken(" aaaaa ' bbbbb")
  5559.  
  5560.         TokenScanDestroy
  5561.  
  5562.  
  5563.  
  5564.                Function  Release the resouces allocated by
  5565.                          TokenScanCreate.
  5566.  
  5567.                  Syntax  TokenScanDestroy()
  5568.  
  5569.                 Returns  Null value.
  5570.  
  5571.         TokenTerm
  5572.  
  5573.  
  5574.  
  5575.                Function  Get the terminator before the current token.
  5576.  
  5577.                  Syntax  TokenTerm()
  5578.  
  5579.                 Returns  A string containing the value of the terminator.
  5580.  
  5581.                 Remarks  The terminator is the whitespace that separates
  5582.                          the current token from the previous token.  It
  5583.                          may be null, for example where there is no
  5584.                          whitespace between a name and an operator.
  5585.  
  5586.                          See the comments in TokenScanCreate for the
  5587.                          effect of TokenTerm when TokenScanCreate has not
  5588.                          been performed.
  5589.  
  5590.  
  5591.  
  5592.  
  5593.  
  5594.  
  5595.         Chapter 6    System Intrinsic Functions                          79
  5596.  
  5597.  
  5598.  
  5599.  
  5600.         TokenType
  5601.  
  5602.  
  5603.  
  5604.                Function  Get the type of the current token.
  5605.  
  5606.                  Syntax  TokenType()
  5607.  
  5608.                 Returns  A string describing the type of the current
  5609.                          token.  Valid values are shown in the table
  5610.                          below.  For more information see the Lexical
  5611.                          Elements chapter.
  5612.  
  5613.                          "NAME"   Name, could be a keyword.
  5614.                          "OPER"   Operator like + or !=
  5615.                          "STRING" String literal, "abcd\nefg", `qwerty`
  5616.                                   or 'a'
  5617.                          "DATE"   Date string "20/9/1953"
  5618.                          "FLOAT"  Number with a decimal point 123.45
  5619.                          "INT"    Integer value 12344
  5620.                          "EOT"    End of text. When no errors occur, the
  5621.                                   last token will have this type.
  5622.                          "CHAR"   A character that is not one of the
  5623.                                   above types.
  5624.  
  5625.                 Remarks  See the comments in TokenScanCreate for the
  5626.                          effect of TokenType when TokenScanCreate has not
  5627.                          been performed.
  5628.  
  5629.         TokenValue
  5630.  
  5631.  
  5632.  
  5633.                Function  Get the value of the current token.
  5634.  
  5635.                  Syntax  TokenValue()
  5636.  
  5637.                 Returns  A string containing the value of the current
  5638.                          token.
  5639.  
  5640.                 Remarks  See the comments in TokenScanCreate for the
  5641.                          effect of TokenValue when TokenScanCreate has not
  5642.                          been performed.
  5643.  
  5644.         Unbunch
  5645.  
  5646.  
  5647.  
  5648.                Function  Break a bunch into components.
  5649.  
  5650.                  Syntax  Unbunch (bunch, &var ...)
  5651.  
  5652.                 Returns  Number of items in the bunch.  If the first
  5653.                          argument is not a bunch,  0 is returned.
  5654.  
  5655.                 Remarks  Used to extract the component parts of the bunch
  5656.                          into the variables, which should be passed by
  5657.                          reference.
  5658.  
  5659.  
  5660.  
  5661.  
  5662.         80                                           Nadir Reference Manual
  5663.  
  5664.  
  5665.  
  5666.  
  5667.                          If the first argument is not a bunch, the first
  5668.                          variable is set to that value.
  5669.  
  5670.                          Any extra variables are set to the null value.
  5671.  
  5672.                 Example  l_ocal = Bunch(1, 2, "abcd", 45.2);
  5673.                          r = Unbunch(l_ocal, &loc1, &loc2, &loc3, &loc4,
  5674.                          &loc5);
  5675.  
  5676.                          This code would set loc1 to 1, loc2 to 2, loc3 to
  5677.                          "abcd", loc4 to 45.2, and loc5 to the null value.
  5678.                          r would be set to 4.
  5679.  
  5680.  
  5681.  
  5682.  
  5683.  
  5684.  
  5685.  
  5686.  
  5687.  
  5688.  
  5689.  
  5690.  
  5691.  
  5692.  
  5693.  
  5694.  
  5695.  
  5696.  
  5697.  
  5698.  
  5699.  
  5700.  
  5701.  
  5702.  
  5703.  
  5704.  
  5705.  
  5706.  
  5707.  
  5708.  
  5709.  
  5710.  
  5711.  
  5712.  
  5713.  
  5714.  
  5715.  
  5716.  
  5717.  
  5718.  
  5719.  
  5720.  
  5721.  
  5722.  
  5723.  
  5724.  
  5725.  
  5726.  
  5727.  
  5728.  
  5729.         Chapter 6    System Intrinsic Functions                          81
  5730.  
  5731.  
  5732.  
  5733.  
  5734.         APPENDIX  A    SYSTEM  PARAMETERS
  5735.  
  5736.  
  5737.  
  5738.  
  5739.  
  5740.                          System parameters are values in the parm symbol
  5741.                          table that are read when Nadir starts processing.
  5742.                          The following section describes each of these
  5743.                          parameters.
  5744.  
  5745.         mdir^threshold
  5746.  
  5747.                          The mdir file is an internal work file that keeps
  5748.                          track of the code and data portions of functions
  5749.                          that are loaded in memory.
  5750.  
  5751.                          If the threshold value is not specified, or zero,
  5752.                          a function that is loaded from the mdat file into
  5753.                          memory is retained in memory until the Nadir
  5754.                          program is ended.  The exception to this rule is
  5755.                          when a function is redefined using the Define
  5756.                          keyword in the input file after it has been
  5757.                          loaded into memory, in which case the system will
  5758.                          free the current version in memory, if it is not
  5759.                          in use at the time of being redefined.
  5760.  
  5761.                          When a threshold is specified, the system
  5762.                          attempts to limit the use of memory to store
  5763.                          function code and data to the number of bytes
  5764.                          specified by the threshold.  i.e. If threshold is
  5765.                          100000, the system will limit the memory used to
  5766.                          store code and data areas to 100000 bytes.
  5767.  
  5768.                          To do this, the following processing is
  5769.                          performed.  When a function is called, and it is
  5770.                          not in memory, it is loaded into memory and the
  5771.                          memory usage statistic updated.  Each time it is
  5772.                          called a use count is incremented.  Each time a
  5773.                          return is made from a function, its use count is
  5774.                          decremented.  When a function is called, and the
  5775.                          memory usage is above the threshold, all
  5776.                          functions in memory with a use count of zero are
  5777.                          removed, and the memory usage statistic updated
  5778.                          accordingly.
  5779.  
  5780.         date^format
  5781.  
  5782.                          If date^format is "u", the US date format is
  5783.                          used.  When dates are input or output, the format
  5784.                          mm/dd/yyyy is used.
  5785.  
  5786.                          If date^format is not "u', the Australian format
  5787.                          dd/mm/yyyy is used.
  5788.  
  5789.  
  5790.  
  5791.  
  5792.  
  5793.  
  5794.  
  5795.  
  5796.         82                                           Nadir Reference Manual
  5797.  
  5798.  
  5799.  
  5800.  
  5801.         gui^browser
  5802.  
  5803.                          Name of a program that can be used for browsing
  5804.                          text files in the Windows version.  This program
  5805.                          will take one command line argument, the name of
  5806.                          the file to browse.
  5807.  
  5808.         text^browser
  5809.  
  5810.                          Name of a program that can be used for browsing
  5811.                          text files in the DOS version.  This program will
  5812.                          take one command line argument, the name of the
  5813.                          file to browse.
  5814.  
  5815.         word^Define
  5816.  
  5817.                          If specified, defines what word to use for the
  5818.                          Define keyword when processing input.  The allows
  5819.                          the user to redefine the Define keyword to
  5820.                          another word. eg DEFINE_MACRO.
  5821.  
  5822.         word^Eval
  5823.  
  5824.                          If specified, defines what word to use for the
  5825.                          Eval keyword when processing input.
  5826.  
  5827.         word^If
  5828.  
  5829.                          If specified, defines what word to use for the If
  5830.                          keyword when processing input.
  5831.  
  5832.         word^Elseif
  5833.  
  5834.                          If specified, defines what word to use for the
  5835.                          Elseif keyword when processing input.
  5836.  
  5837.         word^Else
  5838.  
  5839.                          If specified, defines what word to use for the
  5840.                          Else keyword when processing input.
  5841.  
  5842.         word^Endif
  5843.  
  5844.                          If specified, defines what word to use for the
  5845.                          Endif keyword when processing input.
  5846.  
  5847.  
  5848.  
  5849.  
  5850.  
  5851.  
  5852.  
  5853.  
  5854.  
  5855.  
  5856.  
  5857.  
  5858.  
  5859.  
  5860.  
  5861.  
  5862.  
  5863.         Appendix A    System Parameters                                  83
  5864.  
  5865.  
  5866.  
  5867.  
  5868.         APPENDIX  B    SYSTEM  LIMITS
  5869.  
  5870.  
  5871.  
  5872.  
  5873.  
  5874.         Windows Tasks
  5875.  
  5876.                          Maximum Windows tasks -  16 tasks.
  5877.  
  5878.                          This is the number of times the Windows version
  5879.                          of the program can be started simultaneously.
  5880.  
  5881.         Handles
  5882.  
  5883.                          Number of handles -  64 handles.
  5884.  
  5885.                          The handle manager manages the internal pool of
  5886.                          handles.  A handle is returned from the FileOpen
  5887.                          intrinsic functions, as well as the SdCreate,
  5888.                          MsgCreate, PfCreate and PdCreate functions
  5889.                          described in the function reference.
  5890.  
  5891.         File Handles
  5892.  
  5893.                          Number of file handles -  16 handles.
  5894.  
  5895.                          This is the number of handles that may be opened
  5896.                          using the FileOpen intrinsic function.
  5897.  
  5898.         Symbol Tables
  5899.  
  5900.                          Maximum number of symbol tables open at one time
  5901.                          -  7 fixed, 16 user definable.
  5902.  
  5903.                          The fixed symbol tables are univ, glob, parm,
  5904.                          mdat, mlib, data and temp.  Up to 16 other tables
  5905.                          may be opened and accessed at the same time.
  5906.  
  5907.         Symbol Name Size
  5908.  
  5909.                          Maximum size of the internal representation of a
  5910.                          symbol name -  128 bytes.
  5911.  
  5912.                          The internal representation will differ slightly
  5913.                          from the text representation of a symbol name.
  5914.                          The length of the internal representation of each
  5915.                          component can be calculated using the following
  5916.                          table.  The caret separator is not stored in the
  5917.                          internal form.
  5918.  
  5919.                          string    string length plus
  5920.                                    2
  5921.                          integer   5
  5922.                          date      5
  5923.                          float     9
  5924.  
  5925.  
  5926.  
  5927.  
  5928.  
  5929.  
  5930.         84                                           Nadir Reference Manual
  5931.  
  5932.  
  5933.  
  5934.  
  5935.         B-tree Levels
  5936.  
  5937.                          Maximum levels in b-tree -  10 levels.
  5938.  
  5939.                          A b-tree structure is used to store symbol names
  5940.                          and values.  The number of levels in the b-tree
  5941.                          affects the total number of symbols that can be
  5942.                          stored in a data file.  It is felt that this will
  5943.                          be hard to exceed.
  5944.  
  5945.         B-tree Nodes
  5946.  
  5947.                          Maximum number of nodes -  65535 nodes.
  5948.  
  5949.                          The number of nodes or blocks in a symbol table
  5950.                          file is limited to 16 bits.  For 4096 byte blocks
  5951.                          the maximum file size is 256Mbytes.
  5952.  
  5953.         B-tree Node Size
  5954.  
  5955.                          Maximum node size -  65500 bytes.
  5956.  
  5957.                          This is the size in bytes of a block in the file,
  5958.                          used to store one node of the b-tree structure.
  5959.                          By increasing the size of a node, the levels in
  5960.                          the b-tree can decrease, but the node search time
  5961.                          and the memory requirements will increase.
  5962.  
  5963.         Symbol Name and Value Lengths
  5964.  
  5965.                          The combination of the length of the internal
  5966.                          representation of the symbol name and value in a
  5967.                          symbol table is limited by the following :-
  5968.  
  5969.                          nameLen + valueLen + 4  has to be less than
  5970.                          (blkSize - 10) / 2
  5971.  
  5972.                          The internal lengths for the different value
  5973.                          types are :-
  5974.  
  5975.                          string    string length plus
  5976.                                    1
  5977.                          integer   5
  5978.                          date      5
  5979.                          float     9
  5980.  
  5981.         String Size
  5982.  
  5983.                          Maximum string size -  2048 bytes.
  5984.  
  5985.                          This is the maximum length of a string value.
  5986.                          The limit is used internally in a number of
  5987.                          places, including string conversions, eg
  5988.                          StrToLit, StrFromLit, PfFormat and Sd functions
  5989.                          that deal with editing strings.
  5990.  
  5991.         Operand Stack Size
  5992.  
  5993.                          Default stack size -  4096 bytes.
  5994.  
  5995.  
  5996.  
  5997.         Appendix B    System Limits                                      85
  5998.  
  5999.  
  6000.  
  6001.  
  6002.                          This size can be specified by the user by using
  6003.                          the -So command line switch.  The maximum size is
  6004.                          65500.
  6005.  
  6006.                          The operand stack is used to hold the results of
  6007.                          expression evaluation.  The items on the stack
  6008.                          use the number of bytes shown in the following
  6009.                          table.
  6010.  
  6011.                          string    string length plus
  6012.                                    3
  6013.                          integer   7
  6014.                          date      7
  6015.                          float     11
  6016.  
  6017.         Local Value Stack Size
  6018.  
  6019.                          Default stack size -  4096 bytes.
  6020.  
  6021.                          This size can be specified by the user by using
  6022.                          the -Sl command line switch.  The maximum size is
  6023.                          65500.
  6024.  
  6025.                          The local value stack is used to store the values
  6026.                          of local variables for all the active functions.
  6027.  
  6028.                          The element size of each item on the stack is the
  6029.                          same as for the Operand Stack.
  6030.  
  6031.         Parameter Value Stack Size
  6032.  
  6033.                          Stack to store parm values -  512 bytes.
  6034.  
  6035.                          The parameter value stack is used to store the
  6036.                          values of the parm symbols read when Nadir
  6037.                          starts.  The parameters described in the System
  6038.                          Limits Appendix in the Language Reference and the
  6039.                          Function Reference are stored in this stack.
  6040.  
  6041.         Parser Word Size
  6042.  
  6043.                          Maximum word size -  2048 bytes.
  6044.  
  6045.                          The word is used to store the current token from
  6046.                          the input file.  The item most likely to reach
  6047.                          the limit is a string literal.
  6048.  
  6049.         Parser Line Size
  6050.  
  6051.                          Maximum line size -  512 bytes.
  6052.  
  6053.                          This is the size of the buffer used to read data
  6054.                          from the Nadir input file.  If a line is longer
  6055.                          than this value, it is a lottery whether Nadir
  6056.                          will correctly process it.  i.e.  Is a token
  6057.                          split into two when 512 characters are read?
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  
  6064.         86                                           Nadir Reference Manual
  6065.  
  6066.  
  6067.  
  6068.  
  6069.         Parser Argument Names
  6070.  
  6071.                          Stack to store argument names -  512 bytes.
  6072.  
  6073.                          The argument names for the function being
  6074.                          compiled is stored in a stack like the Operand
  6075.                          stack.  Each name will use name length plus 3
  6076.                          bytes on the stack.
  6077.  
  6078.         Parser Local Names
  6079.  
  6080.                          Stack to store local variable names -  1024
  6081.                          bytes.
  6082.  
  6083.                          The local variable names for the function being
  6084.                          compiled is stored in a stack like the Operand
  6085.                          stack.  Each name will use name length plus 3
  6086.                          bytes on the stack.
  6087.  
  6088.         Parser Goto Names
  6089.  
  6090.                          Stack to store goto labels -  512 bytes.
  6091.  
  6092.                          The goto label names for the function being
  6093.                          compiled is stored in a stack like the Operand
  6094.                          stack.  Each name will use name length plus 3
  6095.                          bytes on the stack.
  6096.  
  6097.         Compiled Program and Data Size
  6098.  
  6099.                          Program and Data size -  2048 bytes each.
  6100.  
  6101.                          Each function is converted into an internal
  6102.                          representation that has two parts, code and data.
  6103.                          The code has the instructions, the data has
  6104.                          constants and literal strings.  These values are
  6105.                          stored as strings in the mdat symbol table.
  6106.  
  6107.  
  6108.  
  6109.  
  6110.  
  6111.  
  6112.  
  6113.  
  6114.  
  6115.  
  6116.  
  6117.  
  6118.  
  6119.  
  6120.  
  6121.  
  6122.  
  6123.  
  6124.  
  6125.  
  6126.  
  6127.  
  6128.  
  6129.  
  6130.  
  6131.         Appendix B    System Limits                                      87
  6132.  
  6133.  
  6134.  
  6135.  
  6136.         APPENDIX  C    SYMBOL  TABLE  UTILITY - STU
  6137.  
  6138.  
  6139.  
  6140.  
  6141.  
  6142.                          STU is a utility program that is used to manage
  6143.                          symbol table files.
  6144.  
  6145.                          Symbol table files use a b-tree structure.  The
  6146.                          b-tree files are balanced, i.e. the number of
  6147.                          levels or depth of the tree to each key in the
  6148.                          file at any given time is always the same.
  6149.  
  6150.                          The first block of the file contains the top
  6151.                          level node of the tree.  The uppermost levels in
  6152.                          the tree contain key and pointers to the lower
  6153.                          level nodes.  The leaf nodes contain the keys and
  6154.                          the data associated with each key.  When keys are
  6155.                          stored in a node, repeated characters at the
  6156.                          beginning of the key is not stored for each key.
  6157.  
  6158.                          As keys are added in a random fashion, nodes are
  6159.                          split as they become too large.  The algorithm
  6160.                          used attempts to keep each node at least half
  6161.                          full, with the exception of the top level node.
  6162.                          The stu fstat command can be used to see the
  6163.                          efficiency of the storage.  The stu pack command
  6164.                          can be used  to pack a key file into its most
  6165.                          efficient storage use.  The algorithm has
  6166.                          specially written code to treat a new high key
  6167.                          inserted into a key file.
  6168.  
  6169.                          The algorithm currently used by Nadir to delete
  6170.                          keys sets the value of the key to a null value.
  6171.                          Using the stu pack command will also remove
  6172.                          deleted keys.
  6173.  
  6174.         Command Line Syntax
  6175.  
  6176.  
  6177.  
  6178.                          The Stmbol Table Utility Command Line has the
  6179.                          following format
  6180.  
  6181.                          stu <command> [switches] [file1 [file2]]
  6182.  
  6183.                          The command may be:-
  6184.  
  6185.                          Command   Description
  6186.  
  6187.                          bstat     Print brief statistics for file1.
  6188.  
  6189.                          check     The internal structure of file1 is
  6190.                                    checked and reported on.
  6191.  
  6192.                          copy      The symbols in file1 are copied to a
  6193.                                    new file, file2.
  6194.  
  6195.  
  6196.  
  6197.  
  6198.         88                                           Nadir Reference Manual
  6199.  
  6200.  
  6201.  
  6202.  
  6203.                          dump      Dumps the contents of each symbol or
  6204.                                    key in file1.
  6205.  
  6206.                          fstat     Print full statistics for file1.
  6207.                                    This requires a scan of the file.
  6208.  
  6209.                          pack      Packs file1.  This is similar to copy,
  6210.                                    except output is to a temporary file.
  6211.                                    At the end of processing the original
  6212.                                    file is deleted, and the work file
  6213.                                    renamed to file1.
  6214.  
  6215.                          rebuild   Rebuilds file1.  The program scans the
  6216.                                    file, picks any block that has a valid
  6217.                                    format, and inserts symbols in the
  6218.                                    block into a temporary file.  At the
  6219.                                    end of processing the original file is
  6220.                                    deleted, and the work file renamed to
  6221.                                    file1.
  6222.  
  6223.                          rtest     Random Addition test.  This creates
  6224.                                    file1, and randomly adds keys with
  6225.                                    random values.  Used to test the
  6226.                                    software.
  6227.  
  6228.                          The switches are:-
  6229.  
  6230.                          Switch    Description
  6231.  
  6232.                          -p        At end of program, pause and wait for
  6233.                                    a keystroke.
  6234.  
  6235.                          -e        Pause and wait at end of program only
  6236.                                    if the program errors.
  6237.  
  6238.                          -c        Pause and wait at end of program only
  6239.                                    on severe errors.
  6240.  
  6241.                          -s        Silent mode.
  6242.                                    The program will not produce any
  6243.                                    output.
  6244.  
  6245.                          -n        No progress reports.
  6246.                                    By default, stu shows the operation
  6247.                                    count as it performs its processing
  6248.                                    to give an indication of progress.
  6249.                                    Setting -n will turn off the progress
  6250.                                    reporting.
  6251.  
  6252.                          -t        Display time.
  6253.                                    Each line of output is preceded with
  6254.                                    the time.  If a count of operations
  6255.                                    is shown, a rate of operations per
  6256.                                    second since the operation type was
  6257.                                    started is displayed in the format
  6258.                                    r=nnn.
  6259.  
  6260.  
  6261.  
  6262.  
  6263.  
  6264.  
  6265.         Appendix C    Symbol Table Utility                               89
  6266.  
  6267.  
  6268.  
  6269.  
  6270.                          -T<arg>   Specify parameters for the rtest
  6271.                                    command.  For more details see the
  6272.                                    section on rtest.
  6273.  
  6274.                          -C<num>   num specifies the number of keys to
  6275.                                    add when rtest is performed.
  6276.  
  6277.         STU Commands
  6278.  
  6279.  
  6280.  
  6281.         bstat - Brief Statistics
  6282.  
  6283.                          The following shows example output using the
  6284.                          bstat command.  The bstat command shows
  6285.                          statistics that can be easily and quickly
  6286.                          obtained.
  6287.  
  6288.                 Command  stu bstat mdat.dat
  6289.  
  6290.                  Output  Brief File Statistics mdat.dat
  6291.  
  6292.                          fileSize  . . . . =    102400
  6293.                          blkSize . . . . . =      4096
  6294.                          depth . . . . . . =         2
  6295.  
  6296.                          fileSize is the size of the file in bytes.
  6297.                          blkSize is the block size, the number of bytes in
  6298.                          each node of the file.  depth is the number of
  6299.                          levels in the b-tree structure.  The example file
  6300.                          has 2 levels, the top most level, and the leaf
  6301.                          node, which contains the symbol values.
  6302.  
  6303.         check - Check Integrity
  6304.  
  6305.                          The check command can be used to check the
  6306.                          structure of a symbol table.
  6307.  
  6308.                 Command  stu check mdat.dat
  6309.  
  6310.                  Output  Check Symbol Table mdat.dat
  6311.  
  6312.                          237 symbols found
  6313.                          237 symbols listed
  6314.                          file structure correct
  6315.  
  6316.                          The check command is performed in two phases.
  6317.  
  6318.                          Firstly, each block is read and the contents
  6319.                          checked.  For each leaf node found, a count of
  6320.                          symbols in the node is accumulated.  This is the
  6321.                          symbols found value.
  6322.  
  6323.                          Secondly, the list function is performed,
  6324.                          checking that each symbol name returned is after
  6325.                          the previous in the collating sequence.  This
  6326.                          phase is exited if a symbol is found to be out of
  6327.                          sequence.  The count of the symbols is accumlated
  6328.                          and is the symbols listed value.
  6329.  
  6330.  
  6331.  
  6332.         90                                           Nadir Reference Manual
  6333.  
  6334.  
  6335.  
  6336.  
  6337.                          If all nodes have a valid format and the symbols
  6338.                          found agree with the symbols listed, the message
  6339.                          "file structure correct" is displayed.  The file
  6340.                          in use flag will be reset if no errors are
  6341.                          encountered.
  6342.  
  6343.          check messages  The check command can output a number of
  6344.                          informational messages.  They are :-
  6345.  
  6346.                          Message Text             Comments
  6347.  
  6348.                          file size not a multiple The first block of the
  6349.                          of blocksize             file contains the
  6350.                                                   blocksize.  There must
  6351.                                                   be an integer number of
  6352.                                                   blocks in the file.
  6353.  
  6354.                          block not neatly filled  The unused portion of a
  6355.                          with nulls               node must be filled
  6356.                                                   with nulls.  The block
  6357.                                                   has been scanned
  6358.                                                   correctly, but the data
  6359.                                                   after the scan does not
  6360.                                                   contain nulls
  6361.  
  6362.                          symbol too large         A block was scanned and
  6363.                                                   an invalid symbol
  6364.                                                   length was found.
  6365.  
  6366.                          symbols not in order in  During scanning a block
  6367.                          block                    the symbol names were
  6368.                                                   not in ascending
  6369.                                                   collating sequence.
  6370.  
  6371.                          block scan did not end   Each block contains a
  6372.                          on correct byte          count of the bytes used
  6373.                                                   in a block.  The block
  6374.                                                   scan completed, but not
  6375.                                                   at the correct byte
  6376.                                                   position.
  6377.  
  6378.                          not a valid type byte    Each block has a type
  6379.                                                   byte, root block, index
  6380.                                                   block, leaf block.  An
  6381.                                                   incorrect type byte was
  6382.                                                   found.
  6383.  
  6384.                          symbols found and listed The count of symbols
  6385.                          don't match              found by phase 1 and 2
  6386.                                                   are not equal.
  6387.  
  6388.                          errors found             Shown if any error
  6389.                                                   condition was found
  6390.  
  6391.                          file structure correct   No errors have been
  6392.                                                   found.  The structure
  6393.                                                   of the keyfile is
  6394.                                                   correct.
  6395.  
  6396.  
  6397.  
  6398.  
  6399.         Appendix C    Symbol Table Utility                               91
  6400.  
  6401.  
  6402.  
  6403.  
  6404.         copy - Copy Symbol Table
  6405.  
  6406.                          The copy command can be used to copy the contents
  6407.                          of one symbol file to another.  The destination
  6408.                          file is created.  This is not a file copy.  Each
  6409.                          symbol in the source file is read and inserted
  6410.                          into the destination file.  The resulting file
  6411.                          will have as much information possible in each of
  6412.                          the nodes in the file.
  6413.  
  6414.                 Command  stu copy mdat.dat junk.dat
  6415.  
  6416.                  Output  Copy Symbol Table mdat.dat to junk.dat
  6417.  
  6418.                          237 symbols copied
  6419.  
  6420.         dump - Dump Symbol Table
  6421.  
  6422.                          The dump command shows the contents of each of
  6423.                          the symbol values in a hex style dump.
  6424.  
  6425.                 Command  stu dump mdat.dat
  6426.  
  6427.                  Output
  6428.  
  6429.            Dump File mdat.dat
  6430.  
  6431.  
  6432.            (1) BlackOnWhite^c
  6433.             0000 | 3a 01 00 00 03 16 00 00 00 07 03 30 00 00 00 07
  6434.            |:..........0....|
  6435.             0010 | 03 4b 00 00 00 07 03 64 00 00 00 07 03 78 00 00
  6436.            |.K.....d.....x..|
  6437.             0020 | 00 07 03 8e 00 00 00 07 03 9f 00 00 00 07 02 bc
  6438.            |................|
  6439.             0030 | 00 02 c5 00 02 b5 00 0a 1e 03 07 01 01
  6440.            |.............   |
  6441.  
  6442.            (2) BlackOnWhite^d
  6443.             0000 | 43 6f 6c 6f 75 72 41 72 65 61 42 6c 61 63 6b 4f
  6444.            |ColourAreaBlackO|
  6445.            ....file truncated....
  6446.  
  6447.  
  6448.  
  6449.         fstat - Full Statistics
  6450.  
  6451.                          The following shows example output using the
  6452.                          fstat command.  The fstat command shows more
  6453.                          statistics that the bstat command.  To compile
  6454.                          the statistics, the file is scanned from the
  6455.                          first symbol to the last.
  6456.  
  6457.                 Command  stu fstat mdat.dat
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.  
  6464.  
  6465.  
  6466.         92                                           Nadir Reference Manual
  6467.  
  6468.  
  6469.  
  6470.  
  6471.                  Output  File Statistics mdat.dat
  6472.  
  6473.                          fileSize  . . . . =    102400
  6474.                          blkSize . . . . . =      4096
  6475.                          depth . . . . . . =         2
  6476.  
  6477.                          nameCnt . . . . . =       237
  6478.  
  6479.                          nameBytes . . . . =      3736
  6480.                          nameMin . . . . . =         6
  6481.                          nameMax . . . . . =        30
  6482.                          nameAvg . . . . . =        15
  6483.  
  6484.                          valueBytes  . . . =     60797
  6485.                          valueMin  . . . . =         1
  6486.                          valueMax  . . . . =      1589
  6487.                          valueAvg  . . . . =       256
  6488.  
  6489.                          nameCnt contains the number of symbols in the
  6490.                          table.
  6491.  
  6492.                          nameBytes is the total characters in all the
  6493.                          names.  This is the number of bytes used to store
  6494.                          the internal representation of the symbol names.
  6495.                          It does not include overhead.
  6496.  
  6497.                          nameMin, nameAvg and nameMax are the minimum,
  6498.                          average and maximum bytes used for the internal
  6499.                          representation of the names.  The text of the
  6500.                          symbol name is not the same as the internal
  6501.                          representation.
  6502.  
  6503.                          valueBytes is the total characters in all the
  6504.                          symbol values..  It does not include overhead.
  6505.  
  6506.                          valueMin, valueAvg and valueMax are the minimum,
  6507.                          average and maximum bytes used for the values.
  6508.  
  6509.         pack - Pack Symbol Table
  6510.  
  6511.                          The pack command can be used to pack the contents
  6512.                          of a file.  This does the same processing as the
  6513.                          copy command.  The pack command will fit as much
  6514.                          information as possible into each block of the
  6515.                          file, and remove deleted symbol names.
  6516.  
  6517.                          The source file, name.ext is copied to a file
  6518.                          called name.$$$, using the stu copy algorithm.
  6519.                          After the copy, name.bak is deleted, if it
  6520.                          exists.  The source name, name.ext is renamed to
  6521.                          name.bak.  The temporary file, name.$$$ is
  6522.                          renamed to name.ext.  Finally, name.bak is
  6523.                          deleted.
  6524.  
  6525.                 Command  stu pack mdat.dat
  6526.  
  6527.                  Output  Pack Symbol Table mdat.dat
  6528.  
  6529.                          237 symbols copied
  6530.  
  6531.  
  6532.  
  6533.         Appendix C    Symbol Table Utility                               93
  6534.  
  6535.  
  6536.  
  6537.  
  6538.  
  6539.  
  6540.         rbuild - Rebuild Symbol Table
  6541.  
  6542.                          The rbuild command may be used to rebuild a file
  6543.                          from a damaged file.  The blocks of the file are
  6544.                          read is the same manner as for the first phase of
  6545.                          the check command.  If the block is a leaf node,
  6546.                          and passes all the block checks, the symbols in
  6547.                          it are inserted into a temporary output file.
  6548.  
  6549.                          After the rebuild, name.bak is deleted, if it
  6550.                          exists.  The source name, name.ext is renamed to
  6551.                          name.bak.  The temporary file, name.$$$ is
  6552.                          renamed to name.ext.  Finally, name.bak is
  6553.                          deleted.
  6554.  
  6555.                 Command  stu rebuild mdat.dat
  6556.  
  6557.                  Output  Rebuild Symbol Table mdat.dat
  6558.  
  6559.                          237 symbols rebuilt
  6560.  
  6561.         rtest - Random Test
  6562.  
  6563.                          The rtest command can be used to test the
  6564.                          operation of the symbol insert functions.  A
  6565.                          number of switches may be used that control the
  6566.                          type of names that are randomly generated and
  6567.                          added to an existing file.  The file can be
  6568.                          checked at regular intervals.
  6569.  
  6570.                          The rtest switches are described in the following
  6571.                          table.
  6572.  
  6573.                          rtest     Description
  6574.                          switch
  6575.  
  6576.                          -Tc<num>  A total count of num additions to the
  6577.                                    file will be attempted.  Because the
  6578.                                    names of the symbols are generated
  6579.                                    randomly, some may fail because the
  6580.                                    name has been used already.  Default
  6581.                                    value is 10000.
  6582.  
  6583.                          -Tt<num>  The file is checked (tested) after
  6584.                                    num additions.  If not specified, num
  6585.                                    for -Tc is assumed.
  6586.  
  6587.  
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.  
  6596.  
  6597.  
  6598.  
  6599.  
  6600.         94                                           Nadir Reference Manual
  6601.  
  6602.  
  6603.  
  6604.  
  6605.                          -Tel<num> The lowest number of elements in the
  6606.                                    name.
  6607.  
  6608.                                    The number of elements is a random
  6609.                                    number between the low and high
  6610.                                    values inclusive.  The type of
  6611.                                    element is chosen in order, the first
  6612.                                    string, second integer, third float,
  6613.                                    fourth date, fifth string and so on.
  6614.                                    Default value is 1.
  6615.  
  6616.                          -Teh<num> The highest number of elements.  Note
  6617.                                    that if -Tr is used, the name can
  6618.                                    have one more element.  Default value
  6619.                                    is 4.
  6620.  
  6621.                          -Trl<num> The low value for the number of
  6622.                                    repeats.  The number of repeats is a
  6623.                                    random number between the low and
  6624.                                    high numbers.  If non zero, then an
  6625.                                    extra element is added to the current
  6626.                                    name for the repeat number of times.
  6627.                                    Default value is 0.
  6628.  
  6629.                          -Trh<num> The high value for the number of
  6630.                                    repeats.  Default value is 0.
  6631.  
  6632.                          -Tvl<num> The low value for the number of
  6633.                                    characters in the value for the
  6634.                                    randomly chosen name.  The size of
  6635.                                    the value is a random value between
  6636.                                    the low and high values, inclusive.
  6637.                                    Default value is 1.
  6638.  
  6639.                          -Tvh<num> The high value for the number of
  6640.                                    characters in the value.  Default
  6641.                                    value is 50.
  6642.  
  6643.                          If any of the high values are lower than the low
  6644.                          values, the high value is set equal to the low
  6645.                          value.
  6646.  
  6647.                 Command  stu rtest -Tc1000 junk.dat
  6648.  
  6649.                  Output  Random Test, file test.dat, add 1000, check every
  6650.                          1000
  6651.                          Name elements 1 - 4
  6652.                          Name repeats  0 - 0
  6653.                          Value length  1 - 50
  6654.  
  6655.                          1000 symbol adds attempted, 14 failed
  6656.  
  6657.                          Check Symbol Table test.dat
  6658.  
  6659.                          986 symbols found
  6660.                          986 symbols listed
  6661.                          file structure correct
  6662.  
  6663.  
  6664.  
  6665.  
  6666.  
  6667.         Appendix C    Symbol Table Utility                               95
  6668.  
  6669.  
  6670.  
  6671.  
  6672.         APPENDIX  D   ERROR MESSAGES
  6673.  
  6674.  
  6675.  
  6676.  
  6677.  
  6678.                          The error messages produced by Nadir use the same
  6679.                          function internally as the Signal and Exit
  6680.                          intrinsic functions.  This appendix provides a
  6681.                          list of the error messages and some extra
  6682.                          description.
  6683.  
  6684.                          The error messages contain a condition class.
  6685.                          The errors are grouped by class.
  6686.  
  6687.         cnd - Condition Handler
  6688.  
  6689.  
  6690.  
  6691.                          The condition handler provides a method for
  6692.                          dealing with errors.  When the Signal and Exit
  6693.                          intrinsic functions are used, condition handler
  6694.                          functions are called.
  6695.  
  6696.                          The condition handler uses the setjmp and longjmp
  6697.                          C functions, and uses a condition handler stack
  6698.                          to save setjmp stack frames.
  6699.  
  6700.         Condition Stack Overflow
  6701.  
  6702.                          A push of a new condition handler caused the
  6703.                          condition handler stack to overflow.  This can be
  6704.                          caused by using the Process intrinsic function
  6705.                          recursively.
  6706.  
  6707.         fm - File Manager
  6708.  
  6709.  
  6710.  
  6711.                          The file manager is used to control the handles
  6712.                          for text files.  Each file opened with the
  6713.                          FileOpen intrinsic function will use one of the
  6714.                          file manager handles.
  6715.  
  6716.         All handles are open
  6717.  
  6718.                          The limit for the number of open files has been
  6719.                          reached.
  6720.  
  6721.         hm - Handle Manager
  6722.  
  6723.  
  6724.  
  6725.                          The handle manager controls a system pool of
  6726.                          handles.  These include the FileOpen handles, and
  6727.                          well as handles created in other modules of
  6728.                          intrinsic functions such as Print Documents and
  6729.                          Screen Dialogues.
  6730.  
  6731.  
  6732.  
  6733.  
  6734.         96                                           Nadir Reference Manual
  6735.  
  6736.  
  6737.  
  6738.  
  6739.         All handles are used
  6740.  
  6741.                          The limit for the number of system handles has
  6742.                          been reached.
  6743.  
  6744.         key - Key File Functions
  6745.  
  6746.  
  6747.  
  6748.                          The key functions are used to manipulate the b-
  6749.                          tree structure that is used to implement the
  6750.                          symbol table file.  The key is the internal
  6751.                          representation of a symbol name.
  6752.  
  6753.         Key and data too long <key>
  6754.  
  6755.                          The sum of the length of the key and the length
  6756.                          of the data has exceeded the maximum allowed.
  6757.  
  6758.         Key Stack Overflow
  6759.  
  6760.                          Each level in the b-tree occupies one frame in
  6761.                          the key stack.  This error will occur when the
  6762.                          maximum number of levels in a symbol table file
  6763.                          has been exceeded.
  6764.  
  6765.         Key too long <key>
  6766.  
  6767.                          The length of the key has exceeded the maximum
  6768.                          allowed.
  6769.  
  6770.         Opening <name> block size incorrect (<filesize> != <size> * <cnt>)
  6771.  
  6772.                          The file whose name is shown as name has been
  6773.                          opened.  The block size, size, and the block
  6774.                          count, cnt have been extracted from the file
  6775.                          header.  When multiplied together, the file size
  6776.                          should result.  If not, this error will be shown.
  6777.                          This will happen when files contain incorrect
  6778.                          data.
  6779.  
  6780.         Opening <name> block size is <act>, not <spec>
  6781.  
  6782.                          The file whose name is shown as name has been
  6783.                          opened.  The block size, act, has been extracted
  6784.                          from the file header.  This error occurs if the
  6785.                          block size, spec, is specified in the SymOpen
  6786.                          call, and it does not equal the actual size of
  6787.                          the file.
  6788.  
  6789.         lex - Lexical Analysis
  6790.  
  6791.  
  6792.  
  6793.                          Lexical Analysis breaks the input file into
  6794.                          tokens.  Examples of tokens are names, operators,
  6795.                          integer and string constants.
  6796.  
  6797.  
  6798.  
  6799.  
  6800.  
  6801.         Appendix D  Error Messages                                       97
  6802.  
  6803.  
  6804.  
  6805.  
  6806.         Unterminated string
  6807.  
  6808.                          This error occurs when the end of the Nadir input
  6809.                          file is encountered before the closing character
  6810.                          of a string literal or code string.
  6811.  
  6812.         mem - Memory Manager
  6813.  
  6814.  
  6815.  
  6816.                          The memory manager performs all allocation and
  6817.                          deallocation of memory.  It can free all
  6818.                          allocated memory when conditions are signalled
  6819.                          and when the Nadir program is terminated.
  6820.  
  6821.         Out of Memory. Current <curr>, Maximum <max>
  6822.  
  6823.                          A request for memory failed.  The current amount
  6824.                          of memory allocated in shown as curr, the maximum
  6825.                          allocated at one time as max.
  6826.  
  6827.         Request size <size> too large
  6828.  
  6829.                          A request was made for size bytes of memory and
  6830.                          was too large.  Under DOS, one allocation cannot
  6831.                          be more than 64K, under Windows an allocation
  6832.                          cannot exceed the memory block size, specified
  6833.                          with the -Sm command line switch.
  6834.  
  6835.         mi - Macro Interpreter
  6836.  
  6837.  
  6838.  
  6839.                          The macro interpreter is the module that
  6840.                          interprets the output of the compilation of the
  6841.                          macro source code.
  6842.  
  6843.         Compiled version <num>, execution version <num>
  6844.  
  6845.                          The version of the Nadir program that was used to
  6846.                          compile a function is different to that being
  6847.                          used to execute it.  The version is an internal
  6848.                          number associated with the mi module, and is
  6849.                          changed when the format of the compiled program
  6850.                          is changed in a way that makes it not execute in
  6851.                          the next version.  i.e.  The Nadir version may
  6852.                          change, but the internal mi version number may
  6853.                          remain unchanged.
  6854.  
  6855.         Stack overflow in <name> stack
  6856.  
  6857.                          The size of the stack has been exhausted.  name
  6858.                          will refer to the type of stack.  Possible values
  6859.                          are described in the following table.
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868.         98                                           Nadir Reference Manual
  6869.  
  6870.  
  6871.  
  6872.  
  6873.                          Stack Type   Description
  6874.  
  6875.                          Operand      The values of function arguments
  6876.                                       and intermediate expression
  6877.                                       evaluation values for all
  6878.                                       functions currently being executed
  6879.                                       are stored in this stack.
  6880.  
  6881.                          Local Value  The values of local variables for
  6882.                                       all functions currently being
  6883.                                       executed are stored in this stack.
  6884.  
  6885.                          Parm Value   The values read from the parm
  6886.                                       symbol table when Nadir starts are
  6887.                                       stored in the parm value stack.
  6888.  
  6889.                          Arg Name     The names of arguments for the
  6890.                                       function being compiled are stored
  6891.                                       in this stack.
  6892.  
  6893.                          Local Name   The names of local variables for
  6894.                                       the function being compiled are
  6895.                                       stored in this stack.
  6896.  
  6897.                          Label Name   The names of labels in the
  6898.                                       function being compiled are stored
  6899.                                       in the label name stack.
  6900.  
  6901.                          Program      The constants and literals in the
  6902.                          Data         function being compiled are stored
  6903.                                       in the program data stack.
  6904.  
  6905.         mif - Macro Intrinsic Functions
  6906.  
  6907.  
  6908.  
  6909.                          This module implements all the system intrinsic
  6910.                          functions described in the Language Reference
  6911.                          Manual.
  6912.  
  6913.         Browser not defined
  6914.  
  6915.                          A text file was to be browsed by the user, but a
  6916.                          browser program was not defined using the parm
  6917.                          parameters. See gui^browser and text^browser in
  6918.                          the Appendix A, System Parameters.
  6919.  
  6920.         Invalid symbol table <stid>
  6921.  
  6922.                          The symbol table name, shown as stid is invalid.
  6923.                          An valid name is univ or glob.  This error occurs
  6924.                          when an invalid name is passed to SymClose or
  6925.                          SymLock.
  6926.  
  6927.  
  6928.  
  6929.  
  6930.  
  6931.  
  6932.  
  6933.  
  6934.  
  6935.         Appendix D  Error Messages                                       99
  6936.  
  6937.  
  6938.  
  6939.  
  6940.         mm - Macro Manager
  6941.  
  6942.  
  6943.  
  6944.                          This module manages the reading and writing of
  6945.                          all the data in the symbol table files.  This
  6946.                          includes the values of the compiled macros and
  6947.                          symbol table values.  A better name might be the
  6948.                          symbol table manager.
  6949.  
  6950.                          In any of the following error messages, stid will
  6951.                          refer to the symbol table name, eg univ, and
  6952.                          filename will be the filename of the symbol table
  6953.                          file.  errtext is error message text and is
  6954.                          described in the vm section.
  6955.  
  6956.         Application cancelled at user's request
  6957.  
  6958.                          The user does not want to wait any longer for a
  6959.                          lock request.  This error is shown after a user
  6960.                          written lock query function has been executed and
  6961.                          has returned with a true boolean value.
  6962.  
  6963.         Cannot create <filename>, <errtext>
  6964.  
  6965.                          The filename is the name of a temporary symbol
  6966.                          table file that could not be created when the
  6967.                          Nadir program starts.
  6968.  
  6969.         Cannot open or create <filename>, <errtext>
  6970.  
  6971.                          The filename is the name of a permanent symbol
  6972.                          table file that could not be either opened or
  6973.                          created when the Nadir program starts.
  6974.  
  6975.         Could not auto lock <stid>, <filename>
  6976.  
  6977.                          A value was assigned to a symbol name.  The
  6978.                          symbol table had not been locked, and the system
  6979.                          was attempting an automatic lock.  This attempt
  6980.                          failed.
  6981.  
  6982.         Could not lock <stid>, <filename>
  6983.  
  6984.                          The system could not lock the symbol table.  This
  6985.                          error is shown if the user written function
  6986.                          SysLockQuery does not exist.
  6987.  
  6988.         Invalid table in symbol <name>
  6989.  
  6990.                          The first component of a symbol name, shown as
  6991.                          name, is not the name of a valid symbol table.
  6992.                          eg. It is not one of the system names or a user
  6993.                          defined name.
  6994.  
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000.  
  7001.  
  7002.         100                                          Nadir Reference Manual
  7003.  
  7004.  
  7005.  
  7006.  
  7007.         Locking <stid>, <filename> for update, write not allowed
  7008.  
  7009.                          An attempt has been made to lock a symbol table
  7010.                          for update, but the user does not have write
  7011.                          permission to the file.
  7012.  
  7013.         Macro Code not found <name>
  7014.  
  7015.                          A function is to be executed and the macro code
  7016.                          string could not be found in mdat or mlib.  name
  7017.                          is the name of the function.
  7018.  
  7019.         Macro Data not found <name>
  7020.  
  7021.                          A function is to be executed and the macro data
  7022.                          string could not be found.  name is the name of
  7023.                          the function.  In this case the macro code string
  7024.                          has been found.
  7025.  
  7026.         No ^ in symbol <name>
  7027.  
  7028.                          A caret was not found in a symbol name.  A caret
  7029.                          must be present because the first component of
  7030.                          the name is the symbol table name.
  7031.  
  7032.         No symbol table name on open or create
  7033.  
  7034.                          A SymOpen or SymCreate function was called and
  7035.                          the table name was empty.
  7036.  
  7037.         Open limit exceeded <stid>
  7038.  
  7039.                          A SymOpen or SymCreate function was called, and
  7040.                          the maximum allowable number of symbol table
  7041.                          files were already opened.
  7042.  
  7043.         Symbol Table <stid>, <filename> not open
  7044.  
  7045.                          A symbol was referenced, but the symbol table was
  7046.                          not open.
  7047.  
  7048.         Symbol Table <stid>, <filename> not properly closed
  7049.  
  7050.                          The symbol table was improperly closed, the
  7051.                          single use command line switch was used, and
  7052.                          there was no user written SysFileRecover function
  7053.                          to perform.
  7054.  
  7055.         Test lock failed, <errtext>
  7056.  
  7057.                          An attempt was made to lock a temporary file on
  7058.                          startup to ensure that the DOS SHARE program has
  7059.                          been loaded.  SHARE had been loaded and the test
  7060.                          lock failed for some other reason.
  7061.  
  7062.         Updating <stid>, <filename>, when locked for read
  7063.  
  7064.                          A symbol value has been assigned in a symbol
  7065.                          table that was locked by SymLock for read lock.
  7066.  
  7067.  
  7068.  
  7069.         Appendix D  Error Messages                                      101
  7070.  
  7071.  
  7072.  
  7073.  
  7074.         Updating <stid>, <filename>, write not allowed
  7075.  
  7076.                          An attempt has been made to modify a symbol
  7077.                          table, when the user does not have write
  7078.                          permission to the file.
  7079.  
  7080.                          When a symbol table is opened, Nadir checks
  7081.                          whether the user has read/write access or read
  7082.                          only access to the file.  When the user has read
  7083.                          only access, Nadir will continue, but will not
  7084.                          allow symbol values to be modified.
  7085.  
  7086.         mp - Macro Parsing
  7087.  
  7088.  
  7089.  
  7090.                          This module processes the Nadir input file.  It
  7091.                          performs the compilation of functions and
  7092.                          produces the syntax error messages.
  7093.  
  7094.         Cannot process input with Runtime version
  7095.  
  7096.                          This error occurs when the Runtime version of the
  7097.                          program is used to process an input file.
  7098.  
  7099.         Invalid pre process flags <flags>
  7100.  
  7101.                          One of the flags in a call to the PreProcessSet
  7102.                          intrinsic function was not valid.
  7103.  
  7104.         Syntax Errors
  7105.  
  7106.                          When a function is compiled with the Define
  7107.                          keyword in the input file, many syntax errors may
  7108.                          be produced.  The message shown to the user is
  7109.                          formatted in one of the following ways.  In all
  7110.                          cases msg refers to the text of the syntax error.
  7111.  
  7112.         <msg> at end of input
  7113.  
  7114.                          This occurs when the syntax error occurs at the
  7115.                          end of the input.
  7116.  
  7117.         <msg> at word <word>
  7118.  
  7119.                          This is shown when a string is being processed.
  7120.                          Strings can be processed using the Process
  7121.                          intrinsic function.  word is the current lexical
  7122.                          token when the error occured.
  7123.  
  7124.         <msg> at word <word> on line <num>, <line>
  7125.  
  7126.                          This is shown when the input file is being
  7127.                          processed.  word is the current lexical token
  7128.                          when the error occured, num is the line number of
  7129.                          the current line in the input file, and line the
  7130.                          text of the current line.
  7131.  
  7132.  
  7133.  
  7134.  
  7135.  
  7136.         102                                          Nadir Reference Manual
  7137.  
  7138.  
  7139.  
  7140.  
  7141.         Syntax Error Text
  7142.  
  7143.                          Each of the syntax errors follow.
  7144.  
  7145.         break not in loop or switch
  7146.  
  7147.                          A break statement was encountered but was not in
  7148.                          a do, do while, for or switch statement.
  7149.  
  7150.         case not in switch
  7151.  
  7152.                          A case statement was encountered but was not in a
  7153.                          switch statement.
  7154.  
  7155.         continue not in loop
  7156.  
  7157.                          A continue statement was encountered but was not
  7158.                          in a do, do while or for statement.
  7159.  
  7160.         default not in switch
  7161.  
  7162.                          A default statement was encountered that was not
  7163.                          in a switch statement.
  7164.  
  7165.         Duplicate arg name
  7166.  
  7167.                          One of the argument names in the argument name
  7168.                          list after the Define keyword is duplicated.
  7169.  
  7170.         Expected (
  7171.  
  7172.                          The syntax of a statement expected a left
  7173.                          parenthesis, but one was not seen.
  7174.  
  7175.         Expected ( or {
  7176.  
  7177.                          The syntax of a statement expected a left
  7178.                          parenthesis or left brace, but one was not seen.
  7179.  
  7180.         Expected )
  7181.  
  7182.                          The syntax of a statement expected a right
  7183.                          parenthesis, but one was not seen.
  7184.  
  7185.         Expected ) or end of input
  7186.  
  7187.                          This occurs when processing the Eval keyword.
  7188.                          The end of input or a right parenthesis was not
  7189.                          found after the Eval expression.
  7190.  
  7191.         Expected :
  7192.  
  7193.                          The syntax of a statement expected a colon, but
  7194.                          one was not seen.
  7195.  
  7196.         Expected ;
  7197.  
  7198.                          The syntax of a statement expected a semicolon,
  7199.                          but one was not seen.
  7200.  
  7201.  
  7202.  
  7203.         Appendix D  Error Messages                                      103
  7204.  
  7205.  
  7206.  
  7207.  
  7208.         Expected a compound statement
  7209.  
  7210.                          The syntax after the Define keyword expects a
  7211.                          compound statement, but one was not seen.
  7212.  
  7213.         Expected a label
  7214.  
  7215.                          The syntax of a goto statement expected a label
  7216.                          to be present, but one was not seen.
  7217.  
  7218.         Expected a statement
  7219.  
  7220.                          The syntax of a statement expected a statement to
  7221.                          be present, but one was not seen.
  7222.  
  7223.         Expected an expression
  7224.  
  7225.                          The syntax of a statement expected an expression,
  7226.                          but one was not seen.
  7227.  
  7228.         Expected Endif
  7229.  
  7230.                          An Endif keyword was expected in the input file,
  7231.                          but was not seen.  This occurs at the end of the
  7232.                          input file.
  7233.  
  7234.         Expected name after Define
  7235.  
  7236.                          A function name was not found after the Define
  7237.                          keyword in the input file.
  7238.  
  7239.         Expected ]
  7240.  
  7241.                          The syntax of the statement expected a right
  7242.                          bracket, but one was not seen.
  7243.  
  7244.         Expected ^
  7245.  
  7246.                          The syntax of the statement expected a caret, but
  7247.                          one was not seen.
  7248.  
  7249.         Expected }
  7250.  
  7251.                          The syntax of the statement expected a right
  7252.                          brace, but one was not seen.
  7253.  
  7254.         Invalid arg list
  7255.  
  7256.                          An invalid argument list was found.  A valid
  7257.                          argument list has a left parenthesis, none or
  7258.                          more arguments separated by commas, ending with a
  7259.                          right parenthesis.
  7260.  
  7261.  
  7262.  
  7263.  
  7264.  
  7265.  
  7266.  
  7267.  
  7268.  
  7269.  
  7270.         104                                          Nadir Reference Manual
  7271.  
  7272.  
  7273.  
  7274.  
  7275.         Invalid arg name list
  7276.  
  7277.                          The argument name list after the function name
  7278.                          after the Define keyword was invalid.  A valid
  7279.                          argument list has a left parenthesis, none or
  7280.                          more argument names separated by commas, ending
  7281.                          with a right parenthesis.
  7282.  
  7283.         Invalid table name
  7284.  
  7285.                          A macro name containing a caret was specified
  7286.                          after the Define keyword.  The name component
  7287.                          before the first caret was an invalid symbol
  7288.                          table name.
  7289.  
  7290.         Label <name> already defined
  7291.  
  7292.                          The label, shown as name has already been defined
  7293.                          in the current function.
  7294.  
  7295.         Label <name> not defined
  7296.  
  7297.                          A label was referenced in a function, but was not
  7298.                          defined.
  7299.  
  7300.         More than one default
  7301.  
  7302.                          There was more than one default statement found
  7303.                          in a switch statement.
  7304.  
  7305.         next arg not a symbol
  7306.  
  7307.                          The argument of a next function is not a valid
  7308.                          symbol name.
  7309.  
  7310.         No lvalue after &
  7311.  
  7312.                          The reference operator was encountered, but was
  7313.                          not followed by an lvalue.
  7314.  
  7315.         No matching If
  7316.  
  7317.                          An Elseif, Else or Endif keyword was found in the
  7318.                          input file without a matching If keyword.
  7319.  
  7320.         No subscript after argv
  7321.  
  7322.                          The argv was not followed by a left bracket, an
  7323.                          expression and a right bracket.
  7324.  
  7325.         No while after do
  7326.  
  7327.                          The while reserved word of the do statement was
  7328.                          not found.
  7329.  
  7330.         prev arg not a symbol
  7331.  
  7332.                          The argument of a prev function is not a valid
  7333.                          symbol name.
  7334.  
  7335.  
  7336.  
  7337.         Appendix D  Error Messages                                      105
  7338.  
  7339.  
  7340.  
  7341.  
  7342.         Subs expr too complex
  7343.  
  7344.                          There were too many operands in a subscript
  7345.                          expression.  The complexity of the expression in
  7346.                          a subscript is limited to a fairly generous size.
  7347.  
  7348.         Too much code
  7349.  
  7350.                          The size of the code string exceeded the maximum
  7351.                          allowable during the compilation of a function.
  7352.                          The function has too much code and needs to be
  7353.                          broken into smaller pieces.
  7354.  
  7355.         Too much data
  7356.  
  7357.                          The size of the data string exceeded the maximum
  7358.                          allowable during the compilation of a function.
  7359.                          As with the code string, the function may have to
  7360.                          be broken into smaller pieces.
  7361.  
  7362.         n - The main program
  7363.  
  7364.  
  7365.  
  7366.                          This is the driver program that reads and parses
  7367.                          the command line switches, and provides the main
  7368.                          processing loop.
  7369.  
  7370.         Cannot find macro <name>
  7371.  
  7372.                          A macro, with a name of name could not be found.
  7373.                          This will the value of either the -a, -b or -e
  7374.                          command line switch.
  7375.  
  7376.         Cannot open <name>
  7377.  
  7378.                          A file, displayed as name, could not be opened.
  7379.                          This can be the input file name, -i command line
  7380.                          switch, the output file name, -o, or the library
  7381.                          file name, -L, or -l.
  7382.  
  7383.         Cannot specify both -e and -p
  7384.  
  7385.                          Only one of the command line switches -e and -p
  7386.                          may be specified.  -e will execute a macro, while
  7387.                          -p is used to process a string.
  7388.  
  7389.         Single Use mode not available under Windows
  7390.  
  7391.                          The -s command line option for single use mode,
  7392.                          cannot be specified on the Windows version of
  7393.                          Nadir.
  7394.  
  7395.  
  7396.  
  7397.  
  7398.  
  7399.  
  7400.  
  7401.  
  7402.  
  7403.  
  7404.         106                                          Nadir Reference Manual
  7405.  
  7406.  
  7407.  
  7408.  
  7409.         st - Symbol Table
  7410.  
  7411.  
  7412.  
  7413.                          The symbol table functions are used to convert a
  7414.                          symbol name to and from the internal form used in
  7415.                          the symbol table files.  The module also has the
  7416.                          function that is used to compare 2 names in their
  7417.                          internal format.
  7418.  
  7419.         Element in symbol <name> too long
  7420.  
  7421.                          One of the components in the symbol, shown as
  7422.                          name is too long to represent the length in one
  7423.                          character.
  7424.  
  7425.         Invalid key
  7426.  
  7427.                          An internal representation  was being converted
  7428.                          to the symbol name, and an invalid component type
  7429.                          was found.  This occurs when a symbol table file
  7430.                          is corrupt.
  7431.  
  7432.         Key for symbol <name> too long
  7433.  
  7434.                          A symbol name, shown in name, was converted to
  7435.                          the internal form.  The result was longer than
  7436.                          the maximum length.
  7437.  
  7438.         vm - Virtual Memory
  7439.  
  7440.  
  7441.  
  7442.                          The vm module implements a buffering technique
  7443.                          that is used by the module used to implement the
  7444.                          symbol table files.  This is the module that
  7445.                          physically opens the symbol table files and
  7446.                          performs the input and output to the files.
  7447.  
  7448.                          Several of the errors include a name and error
  7449.                          text.  The name is the filename.  It may the the
  7450.                          right hand end of long file names.
  7451.  
  7452.                          The text is the error text made using the errno
  7453.                          from the C library routines.  Error texts are :-
  7454.  
  7455.                          Error text          Remarks
  7456.  
  7457.                          No such file or
  7458.                          directory
  7459.                          Too many open files
  7460.                          Permission denied
  7461.                          No such device
  7462.                          File already exists
  7463.                          Locking violation
  7464.  
  7465.  
  7466.  
  7467.  
  7468.  
  7469.  
  7470.  
  7471.         Appendix D  Error Messages                                      107
  7472.  
  7473.  
  7474.  
  7475.  
  7476.                          errno = <num>       If the error message is
  7477.                                              obscure or not likely to
  7478.                                              arise.  num will be the
  7479.                                              value of errno when the
  7480.                                              failure occurred.
  7481.  
  7482.         Read error, file <name>, <text>
  7483.  
  7484.                          An error occurred when performing a read from a
  7485.                          symbol table file.
  7486.  
  7487.         Seek error, file <name>, <text>
  7488.  
  7489.                          The error occurred when performing a seek, moving
  7490.                          the file pointer in a symbol table file prior to
  7491.                          a read or write.
  7492.  
  7493.         SHARE.EXE not loaded
  7494.  
  7495.                          A region of a file was locked with the locking C
  7496.                          library function.  The return status indicated
  7497.                          that the DOS program SHARE.EXE has not been
  7498.                          loaded.
  7499.  
  7500.                          This program has to be loaded before the locking
  7501.                          functions will work.  See the DOS SHARE command.
  7502.  
  7503.         Write error, file <name>, <text>
  7504.  
  7505.                          An error occurred when writing a block to a
  7506.                          symbol table file.
  7507.  
  7508.         Write error, file <name>, len != bufsize
  7509.  
  7510.                          A write was performed, and the length returned
  7511.                          was not equal to the amount requested.  This will
  7512.                          be the block size for the symbol table file.
  7513.  
  7514.  
  7515.  
  7516.  
  7517.  
  7518.  
  7519.  
  7520.  
  7521.  
  7522.  
  7523.  
  7524.  
  7525.  
  7526.  
  7527.  
  7528.  
  7529.  
  7530.  
  7531.  
  7532.  
  7533.  
  7534.  
  7535.  
  7536.  
  7537.  
  7538.         108                                          Nadir Reference Manual
  7539.  
  7540.  
  7541.  
  7542.  
  7543.         INDEX
  7544.  
  7545.  
  7546.  
  7547.  
  7548.  
  7549.                                            Dump  55, 58
  7550.         A
  7551.                                            E
  7552.         Addition operator +  43
  7553.         argc  23, 40                       Else  18, 83
  7554.         Argument                           Elseif  18, 83
  7555.           pass by reference  24, 40        Endif  18, 83
  7556.           pass by value  23                Equality operators  44
  7557.         argv  23, 38                       Escape sequence  6
  7558.         Assignment expression  45          Eval  17, 83
  7559.         autoexec.bat  8                    Exit  56, 96
  7560.                                            Expansion rules  19
  7561.         B                                  Explode  56
  7562.                                            Expression  34, 46
  7563.         b-tree structure  85                 evaluation  17
  7564.         Boolean value  26                    primary  37
  7565.         Break statement  52                  statement  49
  7566.         Bunch  53                            syntax  35
  7567.                                            Expression evaluation  17
  7568.         C
  7569.                                            F
  7570.         Case statement  51
  7571.         Code string  6                     FieldType  57
  7572.         Collating sequence  28             FileClose  57
  7573.         Command line  8                    FileColumn  57
  7574.         Comment  4, 19                     FileDump  57
  7575.         Compound statement  17, 47, 48     FileIndentSet  58
  7576.         Condition Handler  96              FileLineGet  58
  7577.         Conditional expression  45         FileOpen  57, 58, 84, 96
  7578.         config.sys  8                      FilePrint  59
  7579.         Continue statement  52             FileRemove  60
  7580.                                            Floating point number  7
  7581.         D                                  FloatToInt  60
  7582.                                            For statement  51
  7583.         Data directory  11                 Function  22
  7584.         Date format  82                      arguments  22, 40
  7585.         DateDay  53                          call  39
  7586.         DateDayName  53                      return value  23
  7587.         DateMonth  54                      Function name  22, 39
  7588.         DateMonthEnd  54
  7589.         DateMonthName  54                  G
  7590.         DateMonthStart  54
  7591.         DateToday  55                      Global symbol table  13
  7592.         DateYear  55                       Goto statement  52
  7593.         Default statement  51
  7594.         Default symbol tables  13          I
  7595.         Define  16, 22, 39, 47, 82, 83
  7596.         Developer's Kit  1, 39, 53         If  18, 83
  7597.         Division operator /  42            If statement  50
  7598.         Do statement  50                   Input file  4, 8, 9, 13, 14,
  7599.         DOS Share  8, 12, 108              20, 22, 47, 61, 63
  7600.         DOS version  8, 66, 67, 76, 77,    Integer  7
  7601.         83                                 Intrinsic function  22
  7602.  
  7603.  
  7604.  
  7605.         Index                                                           109
  7606.  
  7607.  
  7608.  
  7609.  
  7610.         K                                  Parenthesis ()  41
  7611.                                            PreProcessSet  63
  7612.         Keyword  4                         prev operator  29, 41
  7613.           redefining  16                   Print  15, 60, 64
  7614.                                            Process  65
  7615.         L
  7616.                                            R
  7617.         Label statement  49
  7618.         Level  60                          Relational operators  43
  7619.         Lexical analysis  20, 79, 97       Return statement  49
  7620.         Lexical elements  4                Runtime version  8
  7621.         LineCurr  20, 61, 62
  7622.         LineGet  20, 61                    S
  7623.         LineNum  63
  7624.         Local value stack  12, 86          Signal  66, 74, 96
  7625.         Local variable  12                 Single user mode  12
  7626.         Logical and operator &&  44        Spawn  66
  7627.         Logical negation operator !  41    SpawnRestart  66
  7628.         Logical operator  26               StrCat  67
  7629.         Logical or operator ||  45         StrFromAscii  67
  7630.         Lvalue  38                         StrFromLit  67, 72
  7631.                                            StrFromQuoted  68
  7632.         M                                  String
  7633.                                              constant  6
  7634.         Macro  22                            literal  6
  7635.           arguments  15                      size  85
  7636.           data symbol table  13            String concatenation operator .
  7637.           definition  16                   43
  7638.           library  10                      StrLen  69
  7639.           library symbol table  14         StrMatch  70
  7640.         Macro data symbol table  11        StrPos  70
  7641.         Macro name  16                     StrSubs  71
  7642.         Memory block  12                   StrToAscii  71
  7643.         Modulus operator %  42             StrToLit  68, 71
  7644.         Multiplication operator *  42      StrToLower  72
  7645.                                            StrToUpper  72
  7646.         N                                  Subscripting  27
  7647.                                              function name  29
  7648.         Name  4                              symbol table name  29
  7649.         next operator  29, 40              Subtraction operator -  43
  7650.         Null statement  49                 Switch statement  51
  7651.         Null value  26                     Symbol  13, 38
  7652.                                              name  27, 84, 85
  7653.         O                                    table  27, 38, 84
  7654.                                              value  85
  7655.         Operand conversion rules  28,      Symbol Table Utility  75, 88
  7656.         31                                 SymClose  72, 74
  7657.         Operand stack  12, 86              SymCreate  72
  7658.         Operator  5                        SymLock  73
  7659.           precedence  35                   SymLockQuery  74
  7660.         Operators  34                      SymOpen  72, 73, 74
  7661.         Output file  8, 9, 55, 63, 64      SymRemove  75
  7662.         OutputColumn  63                   SysFileRecover  13
  7663.         OutputIndentSet  63                System  76
  7664.                                            SystemRestart  76
  7665.         P                                  SysType  77
  7666.  
  7667.         Parameter symbol table  12, 14
  7668.         Parameter value stack  86
  7669.  
  7670.  
  7671.  
  7672.         110                                          Nadir Reference Manual
  7673.  
  7674.  
  7675.  
  7676.  
  7677.         T
  7678.  
  7679.         TaskNum  77
  7680.         Temporary file directory  12
  7681.         TimeNow  77
  7682.         Token intrinsic functions  20
  7683.         TokenNext  20, 77
  7684.         TokenScanCreate  78
  7685.         TokenScanDestroy  79
  7686.         TokenTerm  79
  7687.         TokenType  80
  7688.         TokenValue  80
  7689.  
  7690.         U
  7691.  
  7692.         Unary minus operator -  41
  7693.         Unbunch  53, 80
  7694.         Universal symbol table  12, 13
  7695.         User written function  22
  7696.  
  7697.         V
  7698.  
  7699.         Variable  26
  7700.           date  25
  7701.           float  25
  7702.           integer  25
  7703.           local  26
  7704.           string  25
  7705.         Variable types  24
  7706.  
  7707.         W
  7708.  
  7709.         While statement  50
  7710.         Whitespace  4, 14
  7711.         Windows version  8, 12, 66, 76,
  7712.         77, 83, 84
  7713.  
  7714.  
  7715.  
  7716.  
  7717.  
  7718.  
  7719.  
  7720.  
  7721.  
  7722.  
  7723.  
  7724.  
  7725.  
  7726.  
  7727.  
  7728.  
  7729.  
  7730.  
  7731.  
  7732.  
  7733.  
  7734.  
  7735.  
  7736.  
  7737.  
  7738.  
  7739.         Index                                                           111